macro_rules! ident_str {
($ident:expr) => { ... };
}
Expand description
ident_str!
is a compile-time validated macro that constructs a
&'static IdentStr
from a const &'static str
.
Example
Creating a valid static or const IdentStr
:
use move_core_types::{ident_str, identifier::IdentStr};
const VALID_IDENT: &'static IdentStr = ident_str!("MyCoolIdentifier");
const THING_NAME: &'static str = "thing_name";
const THING_IDENT: &'static IdentStr = ident_str!(THING_NAME);
In contrast, creating an invalid IdentStr
will fail at compile time:
ⓘ
use move_core_types::{ident_str, identifier::IdentStr};
const INVALID_IDENT: &'static IdentStr = ident_str!("123Foo"); // Fails to compile!