Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn foo(x: &mut u32, y: usize, f: fn(usize)) -> u32 {
- *x = 42;
- f(y);
- *x // can we optimize this to 42?
- }
- fn main() {
- let mut x = Box::new(0);
- let x_ptr = &mut *x as *mut u32;
- foo(&mut *x, x_ptr as usize, |y| unsafe { *(y as *mut u32) = 23; } );
- }
Add Comment
Please, Sign In to add comment