Macro arcstr::literal_substr[][src]

macro_rules! literal_substr {
    ($text : expr) => { ... };
}
Expand description

feature = "substr": Create a const Substr.

This is a wrapper that initializes a Substr over the entire contents of a const ArcStr made using arcstr::literal!.

As with arcstr::literal, these require no heap allocation, can be freely cloned and used interchangeably with ArcStrs from the heap, and are effectively “free”.

The main use case here is in applications where Substr is a much more common string type than ArcStr.

Examples

use arcstr::{Substr, literal_substr};
// Works in const:
const EXAMPLE_SUBSTR: Substr = literal_substr!("testing testing");
assert_eq!(EXAMPLE_SUBSTR, "testing testing");

// Or, just in normal expressions.
assert_eq!("Wow!", literal_substr!("Wow!"));