Skip to content

Instantly share code, notes, and snippets.

@espindola
Created December 16, 2021 02:06
Show Gist options
  • Save espindola/4e3bccb61657c0f2ba388eeb8e25f3dc to your computer and use it in GitHub Desktop.
Save espindola/4e3bccb61657c0f2ba388eeb8e25f3dc to your computer and use it in GitHub Desktop.
use std::ops::DerefMut;
struct Foo {
a: i32,
b: bool,
}
fn foo(_: &mut i32, _: bool) {}
fn main() {
let f = Foo { a: 42, b: true };
let mut zed = std::boxed::Box::new(f);
let xyz = &mut zed.deref_mut().a;
//let xyz = &mut zed.a;
foo(xyz, zed.b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment