Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutability support #39

Closed
SoniEx2 opened this issue Mar 29, 2016 · 1 comment

Comments

@SoniEx2
Copy link

commented Mar 29, 2016

Any way to support DerefMut?

@Kimundi

This comment has been minimized.

Copy link
Contributor

commented Apr 13, 2016

Lazy statics behave like regular statics in the sense of only allowing shared, &T access to a value. If you want mutability you need to put your values behind a Mutex, for example:

lazy_static! {
    static ref X: Mutex<u32> = Mutex::new(0);
}

fn main() {
    *X.lock() = 100;
}

@Kimundi Kimundi closed this Apr 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.