Skip to content

Commit de4f1a1

Browse files
committed
Update str::split_at_mut example to demonstrate mutability.
1 parent ea6a657 commit de4f1a1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/liballoc/str.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl str {
330330
/// ```
331331
/// let mut v = String::from("🗻∈🌏");
332332
///
333-
/// assert_eq!(Some("🗻"), v.get(0..4);
333+
/// assert_eq!(Some("🗻"), v.get(0..4));
334334
///
335335
/// // indices not on UTF-8 sequence boundaries
336336
/// assert!(v.get_mut(1..).is_none());
@@ -573,12 +573,16 @@ impl str {
573573
/// Basic usage:
574574
///
575575
/// ```
576-
/// let mut s = "Per Martin-Löf".to_string();
577-
///
578-
/// let (first, last) = s.split_at_mut(3);
576+
/// use std::ascii::AsciiExt;
579577
///
580-
/// assert_eq!("Per", first);
581-
/// assert_eq!(" Martin-Löf", last);
578+
/// let mut s = "Per Martin-Löf".to_string();
579+
/// {
580+
/// let (first, last) = s.split_at_mut(3);
581+
/// first.make_ascii_uppercase();
582+
/// assert_eq!("PER", first);
583+
/// assert_eq!(" Martin-Löf", last);
584+
/// }
585+
/// assert_eq!("PER Martin-Löf", s);
582586
/// ```
583587
#[inline]
584588
#[stable(feature = "str_split_at", since = "1.4.0")]

0 commit comments

Comments
 (0)