about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-08-04 18:01:34 -0400
committerCorey Farwell <coreyf@rwell.org>2017-08-05 08:27:24 -0400
commitde4f1a170f96f7e99f28dda534a7b76010499587 (patch)
tree5e22307ff26ef2f66f7ae270adfd6bb9330ae43f /src/liballoc
parentea6a6571758229382d3fcb3fcc9e273c9b854345 (diff)
downloadrust-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.rs16
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")]