macro_rules! s {
() => { ... };
("") => { ... };
($s: expr) => { ... };
}
Expand description
Create a String
literal
This provides a slightly shorter alternative to creating a String
from a literal.
ยงExamples
Empty strings:
use string_literals::s;
let old = String::new();
let s1 = s!();
let s2 = s!("");
assert!(s1.is_empty());
assert!(s2.is_empty());
Non-empty strings:
use string_literals::s;
let old1 = String::from("Alice");
let old2 = "Alice".to_owned();
let old3 = "Alice".to_string();
let new = s!("Alice");
assert_eq!(new, String::from("Alice"));