macro_rules! arc {
($text:expr $(,)?) => { ... };
($($text:expr),+ $(,)?) => { ... };
}Expand description
Constructs a static ArcStr from a string literal.
ยงExamples
use fastring::{ArcStr, arc};
// Creates an empty, static `ArcStr`
let empty = arc!("");
assert_eq!(&empty, "");
// Creates a non-empty, static `ArcStr`
let foobar = arc!("foobar");
assert_eq!(&foobar, "foobar");
// Cloning the static `ArcStr`.
let foobarr = foobar.clone();
assert!(ArcStr::ptr_eq(&foobar, &foobarr));
assert_eq!(&foobarr, "foobar");
// Dropping the `ArcStr` created by `arc!()` is a no-op.
drop(foobar);
assert_eq!(&foobarr, "foobar");
// Thanks to crate `constcat`, we support concatenation of string literals in `arc!()`.
let foobar = arc!("testing", " ", "foobar");
assert_eq!(foobar, "testing foobar");
assert_eq!(foobar, "testing foobar");