take-if
A tiny utility for conditionally taking the contents from an Option
. See also Option::take
.
use TakeIf;
let mut maybe_greeting = Some;
if let Some = maybe_greeting.take_if else
Usage
Add take-if to your Cargo.toml
:
[]
= "1.0.0"
Import the TakeIf
trait in your modules to add the take_if
method to Option
:
use TakeIf;
let taken = maybe_value.take_if;