rune
rune copied to clipboard
Unwrap on Option is hard to use (moves value)
Lets say you have something like this:
if system.is_server() {
// I know fully qualified domain name is always set for servers, just unwrap it
let fdqn = system.fdqn.unwrap();
}
// Later, in another file or function, configuring a different service:
if system.is_server() {
// I know fully qualified domain name is always set for servers, just unwrap it
let fdqn = system.fdqn.unwrap();
}
This doesn't work, since the first .unwrap() consumes the Option. Option also doesn't implement .clone() so there isn't even a workaround for this. Nor can I use .as_ref() like I could in Rust.
What is the suggested solution (in 0.13 preferably)?
Not intended behavior. Containers shouldn't move values as they are being accessed.