Update str::split_at_mut example to demonstrate mutability.
This commit is contained in:
parent
ea6a657175
commit
de4f1a170f
1 changed files with 10 additions and 6 deletions
|
@ -330,7 +330,7 @@ impl str {
|
||||||
/// ```
|
/// ```
|
||||||
/// let mut v = String::from("🗻∈🌏");
|
/// 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
|
/// // indices not on UTF-8 sequence boundaries
|
||||||
/// assert!(v.get_mut(1..).is_none());
|
/// assert!(v.get_mut(1..).is_none());
|
||||||
|
@ -573,12 +573,16 @@ impl str {
|
||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// use std::ascii::AsciiExt;
|
||||||
|
///
|
||||||
/// let mut s = "Per Martin-Löf".to_string();
|
/// let mut s = "Per Martin-Löf".to_string();
|
||||||
///
|
/// {
|
||||||
/// let (first, last) = s.split_at_mut(3);
|
/// let (first, last) = s.split_at_mut(3);
|
||||||
///
|
/// first.make_ascii_uppercase();
|
||||||
/// assert_eq!("Per", first);
|
/// assert_eq!("PER", first);
|
||||||
/// assert_eq!(" Martin-Löf", last);
|
/// assert_eq!(" Martin-Löf", last);
|
||||||
|
/// }
|
||||||
|
/// assert_eq!("PER Martin-Löf", s);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "str_split_at", since = "1.4.0")]
|
#[stable(feature = "str_split_at", since = "1.4.0")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue