Commit Graph

3394 Commits

Author SHA1 Message Date
Ori Avtalion
bb3360adde book: Add missing punctuation 2015-12-11 18:18:13 +02:00
bors
ee597a8ee1 Auto merge of - Xmasreturns:patch-3, r=steveklabnik
Updated structs.md in the book
2015-12-10 04:54:03 +00:00
Xmasreturns
2adba31682 Fixes from review
Traits -> Field labels
Revert a change to convention
2015-12-09 13:25:53 -08:00
Xmasreturns
6bbe6759a5 Grammar and slight ordering changes 2015-12-09 11:37:57 -08:00
Xmasreturns
99fdf3414f Grammar changes for readability 2015-12-09 10:07:02 -08:00
Steve Klabnik
1f0f7d6fba Rollup merge of - Xmasreturns:patch-1, r=steveklabnik
Changes to readability and some clarifications for beginners
2015-12-09 00:01:17 -05:00
Steve Klabnik
ac2cb1fb7d Rollup merge of - matklad:super-docs, r=steveklabnik
Make clear that `super` may be included in the path several times.

r? @steveklabnik
2015-12-09 00:01:17 -05:00
Xmasreturns
88c407c74f Update traits.md 2015-12-08 14:56:42 -08:00
Xmasreturns
f5a4383b21 Update traits.md
Changes to readability and some clarifications for beginners
2015-12-08 14:38:55 -08:00
Steve Klabnik
de39b2cada Re-order the sections in TRPL
This ordering was significantly more confusing.
2015-12-08 15:14:56 -05:00
bors
85b031b3bc Auto merge of - vyp:doc-typo, r=apasel422 2015-12-06 13:23:43 +00:00
xd1le
85a90a3c20 doc(book/error-handling): fix typo 2015-12-06 20:32:49 +11:00
bors
078aff8928 Auto merge of - thyrgle:concurrency_doc, r=alexcrichton
The example code in the Channels subsection of the rust book give warnings about

    unused result which must be used, #[warn(unused_must_use)] on by default

Added a small pattern match to resolve those warnings.
2015-12-06 08:50:49 +00:00
bors
c4b16384f1 Auto merge of - alexcrichton:stabilize-1.6, r=aturon
This commit is the standard API stabilization commit for the 1.6 release cycle.
The list of issues and APIs below have all been through their cycle-long FCP and
the libs team decisions are listed below

Stabilized APIs

* `Read::read_exact`
* `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`)
* libcore -- this was a bit of a nuanced stabilization, the crate itself is now
  marked as `#[stable]` and the methods appearing via traits for primitives like
  `char` and `str` are now also marked as stable. Note that the extension traits
  themeselves are marked as unstable as they're imported via the prelude. The
  `try!` macro was also moved from the standard library into libcore to have the
  same interface. Otherwise the functions all have copied stability from the
  standard library now.
* `fs::DirBuilder`
* `fs::DirBuilder::new`
* `fs::DirBuilder::recursive`
* `fs::DirBuilder::create`
* `os::unix::fs::DirBuilderExt`
* `os::unix::fs::DirBuilderExt::mode`
* `vec::Drain`
* `vec::Vec::drain`
* `string::Drain`
* `string::String::drain`
* `vec_deque::Drain`
* `vec_deque::VecDeque::drain`
* `collections::hash_map::Drain`
* `collections::hash_map::HashMap::drain`
* `collections::hash_set::Drain`
* `collections::hash_set::HashSet::drain`
* `collections::binary_heap::Drain`
* `collections::binary_heap::BinaryHeap::drain`
* `Vec::extend_from_slice` (renamed from `push_all`)
* `Mutex::get_mut`
* `Mutex::into_inner`
* `RwLock::get_mut`
* `RwLock::into_inner`
* `Iterator::min_by_key` (renamed from `min_by`)
* `Iterator::max_by_key` (renamed from `max_by`)

Deprecated APIs

* `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`)
* `OsString::from_bytes`
* `OsStr::to_cstring`
* `OsStr::to_bytes`
* `fs::walk_dir` and `fs::WalkDir`
* `path::Components::peek`
* `slice::bytes::MutableByteVector`
* `slice::bytes::copy_memory`
* `Vec::push_all` (renamed to `extend_from_slice`)
* `Duration::span`
* `IpAddr`
* `SocketAddr::ip`
* `Read::tee`
* `io::Tee`
* `Write::broadcast`
* `io::Broadcast`
* `Iterator::min_by` (renamed to `min_by_key`)
* `Iterator::max_by` (renamed to `max_by_key`)
* `net::lookup_addr`

New APIs (still unstable)

* `<[T]>::sort_by_key` (added to mirror `min_by_key`)

Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
cc  (doesn't close as `Chars` is still unstable)
Closes 
2015-12-06 04:12:54 +00:00
Alex Crichton
464cdff102 std: Stabilize APIs for the 1.6 release
This commit is the standard API stabilization commit for the 1.6 release cycle.
The list of issues and APIs below have all been through their cycle-long FCP and
the libs team decisions are listed below

Stabilized APIs

* `Read::read_exact`
* `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`)
* libcore -- this was a bit of a nuanced stabilization, the crate itself is now
  marked as `#[stable]` and the methods appearing via traits for primitives like
  `char` and `str` are now also marked as stable. Note that the extension traits
  themeselves are marked as unstable as they're imported via the prelude. The
  `try!` macro was also moved from the standard library into libcore to have the
  same interface. Otherwise the functions all have copied stability from the
  standard library now.
* The `#![no_std]` attribute
* `fs::DirBuilder`
* `fs::DirBuilder::new`
* `fs::DirBuilder::recursive`
* `fs::DirBuilder::create`
* `os::unix::fs::DirBuilderExt`
* `os::unix::fs::DirBuilderExt::mode`
* `vec::Drain`
* `vec::Vec::drain`
* `string::Drain`
* `string::String::drain`
* `vec_deque::Drain`
* `vec_deque::VecDeque::drain`
* `collections::hash_map::Drain`
* `collections::hash_map::HashMap::drain`
* `collections::hash_set::Drain`
* `collections::hash_set::HashSet::drain`
* `collections::binary_heap::Drain`
* `collections::binary_heap::BinaryHeap::drain`
* `Vec::extend_from_slice` (renamed from `push_all`)
* `Mutex::get_mut`
* `Mutex::into_inner`
* `RwLock::get_mut`
* `RwLock::into_inner`
* `Iterator::min_by_key` (renamed from `min_by`)
* `Iterator::max_by_key` (renamed from `max_by`)

Deprecated APIs

* `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`)
* `OsString::from_bytes`
* `OsStr::to_cstring`
* `OsStr::to_bytes`
* `fs::walk_dir` and `fs::WalkDir`
* `path::Components::peek`
* `slice::bytes::MutableByteVector`
* `slice::bytes::copy_memory`
* `Vec::push_all` (renamed to `extend_from_slice`)
* `Duration::span`
* `IpAddr`
* `SocketAddr::ip`
* `Read::tee`
* `io::Tee`
* `Write::broadcast`
* `io::Broadcast`
* `Iterator::min_by` (renamed to `min_by_key`)
* `Iterator::max_by` (renamed to `max_by_key`)
* `net::lookup_addr`

New APIs (still unstable)

* `<[T]>::sort_by_key` (added to mirror `min_by_key`)

Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
Closes 
cc  (doesn't close as `Chars` is still unstable)
Closes 
2015-12-05 15:09:44 -08:00
Christopher Sumnicht
bfb7361540 Uses unwrap instead of pattern matching 2015-12-05 15:01:05 -08:00
Aleksey Kladov
c8b7e24b14 DOCS: update reference about paths 2015-12-05 21:55:34 +03:00
Christopher Sumnicht
658f91a0cc Resolved warnings about unused result 2015-12-05 03:17:18 -08:00
Jake Worth
2217cf1af2 Fix typo 2015-12-04 12:32:36 -05:00
bors
77ed39cfe3 Auto merge of - Kimundi:attributes_that_make_a_statement, r=pnkfelix
See https://github.com/rust-lang/rfcs/pull/16 and https://github.com/rust-lang/rust/issues/15701

- Added syntax support for attributes on expressions and all syntax nodes in statement position.
- Extended `#[cfg]` folder to allow removal of statements, and
of expressions in optional positions like expression lists and trailing
block expressions.
- Extended lint checker to recognize lint levels on expressions and
locals.
- As per RFC, attributes are not yet accepted on `if` expressions.

Examples:
  ```rust
let x = y;
{
        ...
}
assert_eq!((1, #[cfg(unset)] 2, 3), (1, 3));

let FOO = 0;
```

Implementation wise, there are a few rough corners and open questions:
- The parser work ended up a bit ugly.
- The pretty printer change was based mostly on guessing.
- Similar to the `if` case, there are some places in the grammar where a new `Expr` node starts,
  but where it seemed weird to accept attributes and hence the parser doesn't. This includes:
  - const expressions in patterns
  - in the middle of an postfix operator chain (that is, after `.`, before indexing, before calls)
  - on range expressions, since `#[attr] x .. y` parses as  `(#[attr] x) .. y`, which is inconsistent with
    `#[attr] .. y` which would parse as `#[attr] (.. y)`
- Attributes are added as additional `Option<Box<Vec<Attribute>>>` fields in expressions and locals.
- Memory impact has not been measured yet.
- A cfg-away trailing expression in a block does not currently promote the previous `StmtExpr` in a block to a new trailing expr. That is to say, this won't work:
```rust
let x = {
    #[cfg(foo)]
    Foo { data: x }
    #[cfg(not(foo))]
    Foo { data: y }
};
```
- One-element tuples can have their inner expression removed to become Unit, but just Parenthesis can't. Eg, `(#[cfg(unset)] x,) == ()` but `(#[cfg(unset)] x) == error`. This seemed reasonable to me since tuples and unit are type constructors, but could probably be argued either way.
- Attributes on macro nodes are currently unconditionally dropped during macro expansion, which seemed fine since macro disappear at that point?
- Attributes on `ast::ExprParens` will be prepend-ed to the inner expression in the hir folder.
- The work on pretty printer tests for this did trigger, but not fix errors regarding macros:
  - expression `foo![]` prints as `foo!()`
  - expression `foo!{}` prints as `foo!()`
  - statement `foo![];` prints as `foo!();`
  - statement `foo!{};` prints as `foo!();`
  - statement `foo!{}` triggers a `None` unwrap ICE.
2015-12-04 08:46:29 +00:00
Mika Attila
87b865c83c Link to lazy_static crate in Design FAQ
Replace the old link pointing to an out-of-date gist with a
link to the lazy_static crate on crates.io.

We also don't need to state the author, as the crates.io page
shows the authors and owners.
2015-12-03 20:11:29 +01:00
bors
a2f58f3644 Auto merge of - shepmaster:for-loop-into-iterator, r=steveklabnik 2015-12-03 04:34:43 +00:00
Jake Goulding
06e4b709c3 Clarify that a for loop uses IntoIterator 2015-12-02 14:48:10 -05:00
bors
01bd93d310 Auto merge of - JIghtuse:master, r=steveklabnik 2015-12-02 15:06:37 +00:00
Boris Egorov
63bb3e66ee book: Provide link to tuple structs in type aliases chapter 2015-12-02 10:47:53 +06:00
Steve Klabnik
9823511b2a Rollup merge of - salty-horse:guessing_panic, r=steveklabnik
The text mentions ```return```, but what's actually happening is a ```panic!```.
2015-12-01 19:01:42 -05:00
Steve Klabnik
63015e8dc0 Rollup merge of - durka:patch-11, r=steveklabnik
I think this fixes . I basically just repeated some details that were scattered around other places in this document, and emphasized that you probably don't want an `extern crate` or `mod` statement to end up inside a function.
2015-12-01 19:01:42 -05:00
Steve Klabnik
da095eecc7 Rollup merge of - pjungwir:clarify-semver-rules, r=steveklabnik
The documentation shows this:

    [dependencies]

    rand="0.3.0"

and says it allows any version compatible with 0.3.0, but then it says, "If we wanted to use only 0.3.0 exactly, we could use `=0.3.0`." That is very easy to misunderstand, so hopefully this PR will help others not to be as confused as me. :-)
2015-12-01 19:01:41 -05:00
Steve Klabnik
5e4adf96cf Rollup merge of - salty-horse:patch-1, r=steveklabnik
random/secret guess -> secret number.
2015-12-01 19:01:41 -05:00
Ori Avtalion
fa0009136d book: Change mention of unused return to panic! 2015-12-02 01:34:08 +02:00
Alex Burka
ca07c2ec21 trpl: explain how to inhibit rustdoc's auto-main
I think this fixes . I basically just repeated some details that were scattered around other places in this document, and emphasized that you probably don't want an `extern crate` or `mod` statement to end up inside a function.
2015-12-01 18:18:19 -05:00
Paul A. Jungwirth
dfa0cbcb3e Clarify ambiguity about how to ask Cargo for a specific version 2015-12-01 10:03:46 -08:00
Ori Avtalion
4a35a732b7 Fix wording in Guessing Game 2015-12-01 11:59:04 +02:00
Daniel Keep
a34274c8ea trpl: additions & fixes for syntax index.
* `const`: Add reference to raw pointers
* Change `expr!(...)` etc. examples to use `ident` instead.
  *Technically*, it should be `pat`, but that's not how it works in
  practice.
* `|`: add reference to closure syntax.
* Closure syntax entry.
* Indexing and slicing entries.
2015-12-01 19:39:52 +11:00
Steve Klabnik
06df5d8042 Rollup merge of - steveklabnik:last_trpl_fix, r=Manishearth
Along with https://github.com/rust-lang/rust/pull/30121, this should fix the last fallout from https://github.com/rust-lang/rust/pull/29932
2015-11-30 18:02:22 -05:00
Steve Klabnik
30221eaedf Rollup merge of - nilcons-contrib:fix-book-stack, r=steveklabnik
The `f` argument will reference the actual value in the `d` box, not the box in the `bar`'s stack frame.

I am just learning Rust, so I don't know how to explain this well, but just from `f`'s type it is clear that it will be a pointer to an `i32`, not a pointer to a pointer. Some `println!("{:p}", ...)`'s can easily confirm this.

I would actually suggest to remove/simplify this part of the example. This is a subtle issue that can easily confuse people at the early stages of familiarizing with the language. (As I got confused by it. :))
2015-11-30 18:02:21 -05:00
Steve Klabnik
5000bd25d9 Rollup merge of - sourcefrog:doc-casts2, r=Manishearth 2015-11-30 18:02:21 -05:00
Steve Klabnik
e4ab0398ff Rollup merge of - bhargavrpatel:master, r=steveklabnik 2015-11-30 18:02:21 -05:00
Steve Klabnik
4bdb60cc34 Fix path to TRPL in doc README 2015-11-30 15:00:30 -05:00
Martin Pool
b00b32cdaa Correct grammar
Thanks @Manishearth
2015-11-30 10:16:36 -08:00
Martin Pool
f183d7a26e Additional text and examples around casting 2015-11-30 08:02:18 -08:00
Mihaly Barasz
7728742a44 Fix pointer value in the 'complex example'
The `f` argument will reference the actual value in the `d` box, not the
box in the `bar`'s stack frame.
2015-11-30 16:51:38 +01:00
Martin Pool
4a63d9fa2c Remove broken explicit coercion example 2015-11-30 07:42:14 -08:00
Bhargav Patel
7a93a3a821 Change verbiage in Stack & Heap page
Made a small change in the sentence. It seemed confusing to read the word "actual" twice in the sentence; I removed it completely.
2015-11-29 22:18:13 -05:00
bors
15ad1d199b Auto merge of - sourcefrog:doc-casts, r=steveklabnik
Based on the description in 219eca11b0/src/librustc_typeck/check/cast.rs (L11) and https://doc.rust-lang.org/nightly/nomicon/casts.html
2015-11-29 21:10:36 +00:00
Martin Pool
797d5433c9 Rephrased description of casting 2015-11-29 12:00:07 -08:00
Martin Pool
34e6995aa3 Add information about numeric casts, from the nomicon 2015-11-29 11:54:29 -08:00
bors
3db9bee903 Auto merge of - androm3da:master, r=bluss 2015-11-29 16:30:15 +00:00
bors
0b3424321c Auto merge of - tshepang:misc, r=steveklabnik 2015-11-28 18:09:07 +00:00
xd1le
fb5f3faa6b doc(book/ffi): remove duplicate link reference `[libc]' 2015-11-28 16:58:39 +11:00