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
Easily convert third party Errors to String
Why does Cargo create multiple directories for the same registry?
Struct with a generic trait which is also a generic trait
Rustup vs Cargo binaries
How to redirect child process output to stderr?
Why does Rust not permit type inference for local constants?
How do I find the function pointers for tests from the LLVM IR code of a Rust program?
How to check in Rust if architecture is 32 or 64 bit?
How can I succinctly combine many `Result`s of different types?
Why is the produced assembly not equivalent between returning by reference and copy when inlined?
include module from the same directory level [duplicate]
Is there a way to prevent emitted LLVM IR from removing unused functions?
Does Cargo support custom profiles?
Pass mutable reference to an element of a vector as parameter of function alongside with that vector
How to format a String object in Rust? [duplicate]
How do I make rustc-link-search relative to the project location?