pub fn proc_read_state_vec(key: &str) -> Vec<String>
Expand description

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

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 proc_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 proc_init_state("key", "\n") which should result in an empty Vec<String> when the state file is read by proc_read_state_vec.

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

Example

use macro_state::*;

proc_append_state("my_key", "first item").unwrap();
proc_append_state("my_key", "2nd item").unwrap();
assert_eq!(proc_read_state_vec("my_key"), vec!["first item", "2nd item"]);