Macro parse
macro_rules! parse {
($s: expr, $ty: ty) => { ... };
}
Available on crate feature
dep_const_str
only.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);