RosettaCodeData/Task/Address-of-a-variable/Rust/address-of-a-variable-4.rust

6 lines
237 B
Text
Raw Permalink Normal View History

2017-09-23 10:01:46 +02:00
unsafe {
*(0x7ffc8f303130 as *mut usize) = 1;
// Note that this invokes undefined behavior if 0x7ffc8f303130 is uninitialized. In that case, std::ptr::write should be used.
std::ptr::write(0x7ffc8f303130 as *mut usize, 1);
}