write_state!() { /* proc-macro */ }
Expand description

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 trying to write to the state file, the IO error will surface as a compile-time error on the macro call.

Calling read_state! with the same key that was written to in a write_state! call should result in a string literal that matches what was written via write_state!.

Example

write_state!("my key", "some value");
assert_eq!(read_state!("my key"), "some value");