book/listings/ch19-advanced-features/listing-19-10/src/main.rs

16 lines
199 B
Rust

static mut COUNTER: u32 = 0;
fn add_to_count(inc: u32) {
unsafe {
COUNTER += inc;
}
}
fn main() {
add_to_count(3);
unsafe {
println!("COUNTER: {COUNTER}");
}
}