[Solved] Dropping partially moved values after the moved values are dropped
Is there a better way to fix this Yes, but not in stable Rust. You need non-lexical lifetimes: #![feature(nll)] #[derive(Debug)] struct Foo(u32); fn get_foo(bar: &mut Foo) -> Option<&mut u32> { Some(&mut bar.0) } pub fn test() { let x = 5; let y = 6; let mut a = Foo(x); let b = get_foo(&mut a); … Read more