Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRustunsafe and the aliasing modelSingle-choice MCQ

What is the aliasing-model status of this code, and why?

let mut v = vec![1u8, 2, 3]; let ptr = v.as_mut_ptr(); let r: &mut u8 = unsafe { &mut *ptr }; v.push(4); // may reallocate the buffer unsafe { *r = 9; }