Function std::string::as_string
[−]
[src]
pub fn as_string(x: &'a str) -> DerefString<'a>
Unstable
Converts a string slice to a wrapper type providing a &String
reference.
Examples
#![feature(collections)] fn main() { use std::string::as_string; // Let's pretend we have a function that requires `&String` fn string_consumer(s: &String) { assert_eq!(s, "foo"); } // Provide a `&String` from a `&str` without allocating string_consumer(&as_string("foo")); }use std::string::as_string; // Let's pretend we have a function that requires `&String` fn string_consumer(s: &String) { assert_eq!(s, "foo"); } // Provide a `&String` from a `&str` without allocating string_consumer(&as_string("foo"));