|
|
|
|
|
by umanwizard
189 days ago
|
|
> I pretty new to Rust and I’m wondering why global mutables are hard? They're not. fn main() {
unsafe {
COUNTER += 1;
println!("COUNTER = {}", COUNTER);
}
unsafe {
COUNTER += 10;
println!("COUNTER = {}", COUNTER);
}
}
Global mutable variables are as easy in Rust as in any other language. Unlike other languages, Rust also provides better things that you can use instead. |
|