1 2 3 4 5 6 7 8 9 10 11 12 13 14
fn main() { let mut n_nonzero = 0; for i in 1..10000 { // <1> let ptr = i as *const u8; let byte_at_addr = unsafe { *ptr }; if byte_at_addr != 0 { n_nonzero += 1; } } println!("non-zero bytes in memory: {}", n_nonzero); }