rust - How do I initialize a static with calls to non-static functions? -
this question has answer here:
- how can make safe static singleton in rust? 2 answers
- how create global, mutable singleton? 1 answer
what proper way initialize such field, if there 1 @ all?
static args: hashmap<&str, vec<u8>> = ["nonce", "gas_price", "gas_limit", "to", "value", "data"] .iter() .map(|i| (*i, get_random())) .collect();
i error:
error[e0015]: calls in statics limited constant functions, struct , enum constructors --> src/main.rs:3:39 | 3 | static args: hashmap<&str, vec<u8>> = ["nonce", "gas_price", "gas_limit", "to", "value", "data"] | _______________________________________^ starting here... 4 | | .iter() | |___________^ ...ending here
Comments
Post a Comment