Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn foo(x: &mut u32, f: impl FnOnce()) -> u32 {
- *x = 42;
- f();
- *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, || unsafe { *x_ptr = 23; } );
- }
Add Comment
Please, Sign In to add comment