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

Reads the state value for the specified key and parses it as a Vec<String> where each new line is treated as a separate element in the Vec. Should be used in conjunction with append_state! to read and write lists of values from macro state storage.

Returns: a Vec<String>. Throws a compiler error if the specified state key cannot be found.

Note: If you need to initialize a state vec to an empty list, you can use init_state("key", "\n") which should result in an empty Vec<String> when the state file is read by read_state_vec!.

Note: the Vec<String> returned by this macro is in literal form, e.g.

vec!["item 1", "item 2", "item 3"];

Note: This macro is infallible – if any issue occurs trying to read the specified key, it is assumed that we should return an empty Vec.

Example

append_state!("my_key", "first item");
append_state!("my_key", "2nd item");
assert_eq!(read_state_vec!("my_key"), vec!["first item", "2nd item"]);