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

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

Categories

HOME
extjs
keyboard
mpdf
yii
workflow
couchdb
windows-10
mousemove
hid
message-queue
ews
histogram
cryptography
iptables
angular2-template
scheduler
jpa-criteria
driver
xades4j
watch-os-3
spring-amqp
freertos
outlook-restapi
bundler
max-msp-jitter
xbox360
web-deployment
mixpanel
adobe-illustrator
adminlte
bluemix-mobile-services
kamailio
ratio
pubxml
ipa
points
marquee
copy-protection
buildforge
pdfnet
bluemixtools
spinner
variable-variables
cheat-engine
moinmoin
destroy
return-type
google-news
scala-collections
dtd
business-rules
logical
openseadragon
android-4.2-jelly-bean
highlighting
urbit
mercurial-extension
decidable
largenumber
canopy
wso2ml
swagger-maven-plugin
explain
kotlin-android-extensions
subfolder
mxe
google-hangouts
password-recovery
inputbox
reference-counting
usb-flash-drive
strcmp
disjoint-union
cmath
audiotoolbox
live-wallpaper
voice-recording
server-name
netstream
uploading
multidrop-bus
litespeed
snackjs
channelfactory
bass
explicit
android-input-method
objectinstantiation
levels
webclient.uploaddata

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App