Function macro_state::proc_read_state
source · [−]Expand description
An analogue for read_state!
that should only be used within proc macros.
Reads the state value for the specified key
. Since macro_state
functions as a
compile-time key-value store, proc_read_state
attempts to read the state value
associaed with the specified key.
The macro will expand into a string literal representing the state value in the event that a value exists for the provided key.
If no value can be found for the provided key (or in the event of any sort of IO error), the macro will raise a compile-time IO error.
Example
use macro_state::*;
proc_write_state("cool key", "something").unwrap();
assert_eq!(proc_read_state("cool key").unwrap(), "something");
let result = proc_read_state("undefined key");
assert!(matches!(result, Err(_)));