//use std::borrow::Cow; //use std::ffi::CStr; //use std::os::raw::c_char; // //static B: [u8; 10] = [99, 97, 114, 114, 121, 116, 111, 119, 101, 108]; //static C: [u8; 11] = [116, 104, 97, 110, 107, 115, 102, 105, 115, 104, 0]; // //fn main() { // let a = 42; // let b: String; // let c: Cow; // // unsafe { // let b_ptr = &B as *const u8 as *mut u8; // b = String::from_raw_parts(b_ptr, 10, 10); // // let c_ptr = &C as *const u8 as *const c_char; // c = CStr::from_ptr(c_ptr).to_string_lossy(); // } // // println!("{} {} {}", a, b, c); //} //fn main() { // let a: i64 = 42; // let a_ptr = &a as *const i64; // let a_addr: usize = unsafe { std::mem::transmute(a_ptr) }; // // println!("{} {:p} 0x{:x}", a, a_ptr, a_addr + 7); //} //fn main() { // let ptr = 42 as *const Vec; // // unsafe { // let new_addr = ptr.offset(4); // println!("{:p} => {:p}", ptr, new_addr); // } //} //fn main() { // let password = String::from("lousy"); // dbg!(is_strong(password)); // dbg!(is_strong("breakage")); //} // //fn is_strong>(password: T) -> bool { // password.as_ref().len() > 5 //} //use std::mem::drop; // //fn main() { //// let a: i32 = 40; //// let b: Box = Box::new(60); //// dbg!(a + *b); // // let a = Box::new(1); // let b = Box::new(1); // let c = Box::new(1); // // let result1 = *a + *b + *c; // // drop(a); // let d = Box::new(1); // let result2 = *b + *c + *d; // // println!("{} {}", result1, result2); //} fn main() { let mut n_nonzero = 0; for i in 0..10_000 { let ptr = i as *const u8; let byte_at_addr = unsafe { *ptr }; if byte_at_addr != 0 { n_nonzero += 1; } } println!("{}", n_nonzero); }