diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-08-04 18:01:34 -0400 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2017-08-05 08:27:24 -0400 |
| commit | de4f1a170f96f7e99f28dda534a7b76010499587 (patch) | |
| tree | 5e22307ff26ef2f66f7ae270adfd6bb9330ae43f /src/liballoc | |
| parent | ea6a6571758229382d3fcb3fcc9e273c9b854345 (diff) | |
| download | rust-de4f1a170f96f7e99f28dda534a7b76010499587.tar.gz rust-de4f1a170f96f7e99f28dda534a7b76010499587.zip | |
Update str::split_at_mut example to demonstrate mutability.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/str.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index bbdc36b8737..bf375ca0c43 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -330,7 +330,7 @@ impl str { /// ``` /// let mut v = String::from("🗻∈🌏"); /// - /// assert_eq!(Some("🗻"), v.get(0..4); + /// assert_eq!(Some("🗻"), v.get(0..4)); /// /// // indices not on UTF-8 sequence boundaries /// assert!(v.get_mut(1..).is_none()); @@ -573,12 +573,16 @@ impl str { /// Basic usage: /// /// ``` - /// let mut s = "Per Martin-Löf".to_string(); - /// - /// let (first, last) = s.split_at_mut(3); + /// use std::ascii::AsciiExt; /// - /// assert_eq!("Per", first); - /// assert_eq!(" Martin-Löf", last); + /// let mut s = "Per Martin-Löf".to_string(); + /// { + /// let (first, last) = s.split_at_mut(3); + /// first.make_ascii_uppercase(); + /// assert_eq!("PER", first); + /// assert_eq!(" Martin-Löf", last); + /// } + /// assert_eq!("PER Martin-Löf", s); /// ``` #[inline] #[stable(feature = "str_split_at", since = "1.4.0")] |
