@rust WOW that seems overly complicated. Here are two ways to do that much more simply:
https://play.rust-lang.org/?gist=8a178f7ea7fc5fe2b54262205de276b2&version=stable
@kornel Here's a slightly modified version that works with &mut.
@kornel er, helps if I include the link:
https://play.rust-lang.org/?gist=778c9d692bb996a94053c21a55d02cf6&version=stable
@NfNitLoop Eh, my original example was too simplified to show it's about unmovable content, i.e. when you have a reference to a large struct/vec or something uncloneable like a file handle.
This time you're dodging use of references by copying the contents instead.
https://play.rust-lang.org/?gist=43aa49401140a0991c563bd38ea62970
@kornel aaaah. Yeah, in that case, you can simplify things by first take()ing the value. If you can't copy it, move it instead! :)
@NfNitLoop Your code doesn't compile with `&mut Some(5)`, and difficulty of working with &Option (rather than freely movable owned Option) was the whole point of the tip.