We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ab1b1ae + de3fcee commit 444a759Copy full SHA for 444a759
src/libcollections/string.rs
@@ -903,6 +903,19 @@ impl<'a> Deref<String> for DerefString<'a> {
903
}
904
905
/// Convert a string slice to a wrapper type providing a `&String` reference.
906
+///
907
+/// # Examples
908
909
+/// ```
910
+/// use std::string::as_string;
911
912
+/// fn string_consumer(s: String) {
913
+/// assert_eq!(s, "foo".to_string());
914
+/// }
915
916
+/// let string = as_string("foo").clone();
917
+/// string_consumer(string);
918
919
#[experimental]
920
pub fn as_string<'a>(x: &'a str) -> DerefString<'a> {
921
DerefString { x: as_vec(x.as_bytes()) }
0 commit comments