Skip to content

Commit 07cae10

Browse files
committed
Improve doc example for Cow::to_mut.
1 parent 6f3919d commit 07cae10

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/libcollections/borrow.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,16 @@ impl<'a, B: ?Sized> Cow<'a, B>
191191
/// # Examples
192192
///
193193
/// ```
194+
/// use std::ascii::AsciiExt;
194195
/// use std::borrow::Cow;
195196
///
196-
/// let mut cow: Cow<[_]> = Cow::Owned(vec![1, 2, 3]);
197+
/// let mut cow = Cow::Borrowed("foo");
198+
/// cow.to_mut().make_ascii_uppercase();
197199
///
198-
/// let hello = cow.to_mut();
199-
///
200-
/// assert_eq!(hello, &[1, 2, 3]);
200+
/// assert_eq!(
201+
/// cow,
202+
/// Cow::Owned(String::from("FOO")) as Cow<str>
203+
/// );
201204
/// ```
202205
#[stable(feature = "rust1", since = "1.0.0")]
203206
pub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned {

0 commit comments

Comments
 (0)