I have an Option
of a struct that I'd like to pass into a function inside a spawn
closure. I know this Option
will always be Some
because immediately before calling spawn
, I set the variable to Some
. However, inside my function, I'm unable to call unwrap()
because that consumes the Option
and I get an error about "cannot move out of borrowed content". Is there any way, besides the if let Some(_) ...
syntax to get around this issue?
Here is a playground that works, with the unwrap()
commented out that will generate the error: Rust Playground