Function macro_state::proc_write_state
source · [−]Expand description
An analogue for write_state!
that should only be used within proc macros.
Writes the specified value
as the state for the specified state key
. macro_state
itself functions as a compile-time key-value store, and this is how you write a value to a
specific key.
If any IO error occurs while attempting to write to the specified state key, the IO error
will be be returned as the Err
result.
Calling proc_read_state
with the same key that was written to in a proc_write_state
call should result in a string literal that matches what was written via
proc_write_state
.
Example
use macro_state::*;
proc_write_state("my key", "some value").unwrap();
assert_eq!(proc_read_state("my key").unwrap(), "some value");