1
Fork 0

Update str::split_at_mut example to demonstrate mutability.

This commit is contained in:
Corey Farwell 2017-08-04 18:01:34 -04:00
parent ea6a657175
commit de4f1a170f

View file

@ -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")]