Macro strp::parse

source ·
parse!() { /* proc-macro */ }
Expand description

Interally uses try_parse and unwraps the result to parse a single value from a source string.

For more details read the documentation of the strp crate.

let source = "hello world!";
let world = parse!(source => "hello {}!");
assert_eq!(world, "world".to_string());

// As a side effect of `parse` unwrapping and causing a possible
// panic, it is not necessary to give inlined variables intitial
// values
let v;
parse!("value" => "{v}");
asseert_eq!(v, "value".to_string());

// Uses stdin as source.
let number: u32 = parse!("input number: {}");
println!("number: {number})