Macro const_str::parse

source ·
macro_rules! parse {
    ($s: expr, $ty: ty) => { ... };
}
Expand description

Parse a value from a string slice.

The output type must be one of

§Examples

const S1: &str = "true";
const X1: bool = const_str::parse!(S1, bool);
assert_eq!(X1, true);

const S2: &str = "42";
const X2: u32 = const_str::parse!(S2, u32);
assert_eq!(X2, 42);

const S3: &str = "-1";
const X3: i8 = const_str::parse!(S3, i8);
assert_eq!(X3, -1);