These are chat archives for rust-lang/rust

10th
Aug 2015
John C F
@critiqjo
Aug 10 2015 10:11
This message was deleted
Igor Khomenko
@soulfly
Aug 10 2015 14:58
is Weak the same as not mutable reference?
Andy Russell
@euclio
Aug 10 2015 21:12
how can I cast an Option<&mut SomeStruct> to Option<&SomeStruct>?
Erik Hedvall
@Ogeon
Aug 10 2015 21:44

This is one way of doing it:

let mut s = SomeStruct;
let x = Some(&mut s).map(|s| s as &_);

I'm quite sure the call to map will be optimized away, or at least be aggressively inlined.