rust


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

Related Links

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?

Categories

HOME
powerbi
mc
azure-functions
tomcat
apple-push-notifications
workflow
transactions
gentelella
moodle-api
tup
selection
azure-logic-apps
reportviewer
hystrix
driver
heuristics
cname
webstore
complexity-theory
mahout-recommender
sonicwall
rest-assured
scala-ide
exec-maven-plugin
word2vec
office-ui-fabric
coroutine
adminlte
akka-persistence
unity-container
bosun
liferay-6.2
generator
intel
eclipse-emf
chronicle-queue
exchange-server-2010
prompt
beego
bitbake
infopath2010
private-key
android-collapsingtoolbar
xmlunit
devtools
forms-authentication
sbjson
newtons-method
get-event-store
classnotfoundexception
directwrite
head.js
hibernate-ogm
sharpdx
node-apn
watir-webdriver
wikimapia
kendo-editor
dex
predicates
msxml
nrf51
maatwebsite-excel
django-testing
gcloud-node
screen-orientation
gluon-desktop
knife
google-gdk
darwin
alwayson
relational-model
phpredis
phonegap-facebook-plugin
fasterxml
utf8-decode
coding-efficiency
flipboard
meteorite
proxy-server
colon
san
statechart
ui-design
semicolon
handshake
multiscaleimage
datacontracts
downgrade
bass
ccl
spring-modules
subtext
motif
twitter-feed
isapi-redirect

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App