SergioBenitez / state

A Rust library for safe and effortless global and thread-local state management.
Other
209 stars 13 forks source link

Latest rust nightly throws error with provided example #4

Closed Zedjones closed 6 years ago

Zedjones commented 6 years ago

error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants --> src/main.rs:38:38 | 38 | static GLOBAL: state::Storage<u32> = state::Storage::new();

I realize that this is likely due to a change in what are allowed to be global statics, but is there any workaround for this? I'm trying to write a server in Rust which needs to run threads at all times but they also need to referenced back to so I need some way to keep track of them. If this isn't a solution, what would you recommend? Nevermind, I found the State page of the Rocket guide which should work, but the README should still probably be updated.

SergioBenitez commented 6 years ago

You need to enable the const_fn feature on state to get const constructors. This is documented in the README and in the crate's documentation: https://sergio.bz/rustdocs/state/#usage

Zedjones commented 6 years ago

Thank you! I must have completely missed that. Sorry about that.