diff options
| author | bors <bors@rust-lang.org> | 2016-02-18 00:33:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-02-18 00:33:58 +0000 |
| commit | e18f7a1c5af91f8630f3c47f73f490c49b61acde (patch) | |
| tree | 6086c5424b53c30250fe8d0ff9c02415ab660dd5 /src/libstd | |
| parent | 4d3eebff9dc9474f56cdba810edde324130fbc61 (diff) | |
| parent | 27ede43c896fc7343975b8ecd67d208ea6673d53 (diff) | |
| download | rust-e18f7a1c5af91f8630f3c47f73f490c49b61acde.tar.gz rust-e18f7a1c5af91f8630f3c47f73f490c49b61acde.zip | |
Auto merge of #31739 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #31565, #31679, #31694, #31695, #31703, #31720, #31733 - Failed merges:
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 7 | ||||
| -rw-r--r-- | src/libstd/collections/mod.rs | 9 | ||||
| -rw-r--r-- | src/libstd/path.rs | 4 | ||||
| -rw-r--r-- | src/libstd/primitive_docs.rs | 32 |
4 files changed, 24 insertions, 28 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 586fafc2b4a..7220690469c 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1157,9 +1157,10 @@ impl<K, V, S> HashMap<K, V, S> /// /// If the map did not have this key present, `None` is returned. /// - /// If the map did have this key present, the key is not updated, the - /// value is updated and the old value is returned. - /// See the [module-level documentation] for more. + /// If the map did have this key present, the value is updated, and the old + /// value is returned. The key is not updated, though; this matters for + /// types that can be `==` without being identical. See the [module-level + /// documentation] for more. /// /// [module-level documentation]: index.html#insert-and-complex-keys /// diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs index 417261cf4c3..06c14157606 100644 --- a/src/libstd/collections/mod.rs +++ b/src/libstd/collections/mod.rs @@ -397,12 +397,15 @@ //! } //! //! let mut map = BTreeMap::new(); -//! map.insert(Foo { a: 1, b: "baz" }, ()); +//! map.insert(Foo { a: 1, b: "baz" }, 99); //! //! // We already have a Foo with an a of 1, so this will be updating the value. -//! map.insert(Foo { a: 1, b: "xyz" }, ()); +//! map.insert(Foo { a: 1, b: "xyz" }, 100); //! -//! // ... but the key hasn't changed. b is still "baz", not "xyz" +//! // The value has been updated... +//! assert_eq!(map.values().next().unwrap(), &100); +//! +//! // ...but the key hasn't changed. b is still "baz", not "xyz". //! assert_eq!(map.keys().next().unwrap().b, "baz"); //! ``` diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 10ecaed3aef..3798fb76ad6 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1582,8 +1582,10 @@ impl Path { /// Returns a path that, when joined onto `base`, yields `self`. /// + /// # Errors + /// /// If `base` is not a prefix of `self` (i.e. `starts_with` - /// returns false), then `relative_from` returns `None`. + /// returns `false`), returns `Err`. #[stable(since = "1.7.0", feature = "path_strip_prefix")] pub fn strip_prefix<'a, P: ?Sized>(&'a self, base: &'a P) -> Result<&'a Path, StripPrefixError> diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index ad93fe0094a..b840e51873e 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -50,18 +50,21 @@ mod prim_bool { } /// [`String`]: string/struct.String.html /// /// As always, remember that a human intuition for 'character' may not map to -/// Unicode's definitions. For example, emoji symbols such as '❤️' are more than -/// one byte; ❤️ in particular is six: +/// Unicode's definitions. For example, emoji symbols such as '❤️' can be more +/// than one Unicode code point; this ❤️ in particular is two: /// /// ``` /// let s = String::from("❤️"); /// -/// // six bytes times one byte for each element -/// assert_eq!(6, s.len() * std::mem::size_of::<u8>()); +/// // we get two chars out of a single ❤️ +/// let mut iter = s.chars(); +/// assert_eq!(Some('\u{2764}'), iter.next()); +/// assert_eq!(Some('\u{fe0f}'), iter.next()); +/// assert_eq!(None, iter.next()); /// ``` /// -/// This also means it won't fit into a `char`, and so trying to create a -/// literal with `let heart = '❤️';` gives an error: +/// This means it won't fit into a `char`. Trying to create a literal with +/// `let heart = '❤️';` gives an error: /// /// ```text /// error: character literal may only contain one codepoint: '❤ @@ -69,8 +72,8 @@ mod prim_bool { } /// ^~ /// ``` /// -/// Another implication of this is that if you want to do per-`char`acter -/// processing, it can end up using a lot more memory: +/// Another implication of the 4-byte fixed size of a `char`, is that +/// per-`char`acter processing can end up using a lot more memory: /// /// ``` /// let s = String::from("love: ❤️"); @@ -79,19 +82,6 @@ mod prim_bool { } /// assert_eq!(12, s.len() * std::mem::size_of::<u8>()); /// assert_eq!(32, v.len() * std::mem::size_of::<char>()); /// ``` -/// -/// Or may give you results you may not expect: -/// -/// ``` -/// let s = String::from("❤️"); -/// -/// let mut iter = s.chars(); -/// -/// // we get two chars out of a single ❤️ -/// assert_eq!(Some('\u{2764}'), iter.next()); -/// assert_eq!(Some('\u{fe0f}'), iter.next()); -/// assert_eq!(None, iter.next()); -/// ``` mod prim_char { } #[doc(primitive = "unit")] |
