about summary refs log tree commit diff
path: root/src/libcollections/string.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcollections/string.rs')
-rw-r--r--src/libcollections/string.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index a37a26ef22a..be6405dc85a 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -951,12 +951,13 @@ impl<'a> Deref for DerefString<'a> {
 /// # #![feature(collections)]
 /// use std::string::as_string;
 ///
-/// fn string_consumer(s: String) {
-///     assert_eq!(s, "foo".to_string());
+/// // Let's pretend we have a function that requires `&String`
+/// fn string_consumer(s: &String) {
+///     assert_eq!(s, "foo");
 /// }
 ///
-/// let string = as_string("foo").clone();
-/// string_consumer(string);
+/// // Provide a `&String` from a `&str` without allocating
+/// string_consumer(&as_string("foo"));
 /// ```
 #[unstable(feature = "collections")]
 pub fn as_string<'a>(x: &'a str) -> DerefString<'a> {