pub fn proc_init_state(key: &str, default_value: &str) -> Result<String>
Expand description

An analogue for clear_state! that should only be used within proc macros.

Returns the value for the specified key, if it exists. If it does not exist, the key is created and set to the specified default_value, and then the default_value is returned.

Example

use macro_state::*;

proc_write_state("my key", "A").unwrap();
assert_eq!(proc_init_state("my key", "B").unwrap(), "A");
assert_eq!(proc_init_state("other key", "B").unwrap(), "B");