How do I initialize a static with calls to non-static functions? [duplicate]
This question already has an answer here: How can you make a safe static singleton in Rust? 2 answers How do I create a global, mutable singleton? 1 answer What is proper way to initialize such a field, if there is one at all? static ARGS: HashMap<&str, Vec<u8>> = ["nonce", "gas_price", "gas_limit", "to", "value", "data"] .iter() .map(|i| (*i, get_random())) .collect(); I get the error: error[E0015]: calls in statics are limited to constant functions, struct and 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
Why is a Cell used to create unmovable objects?
“entry point could not be located” when running program on Windows
Does dereference equal to a function call?
Should I use Rust 1.0-alpha or the nightly version?
How to do a binary search on a Vec of floats?
Having a child modify its parent
How do I access the data sent over UDP?
How to idiomatically copy a slice?
Recursive types and arrays
Can I determine the zero value of generic types?
How to slice a large Vec<i32> as &[u8]?
How to parse i64 from a string? [duplicate]
Why is variable scope dependent on the definition order?
Warning on “unstable” directive
How can I pass a socket as an argument to a function being called within a thread?
error: cannot move out of borrowed content on &mut self