pub trait IntoOptionwhere
Self: Sized,{
// Provided methods
fn some_if(self, predicate: bool) -> Option<Self> { ... }
fn with_some_if<F>(self, predicate: F) -> Option<Self>
where F: FnOnce(&Self) -> bool { ... }
fn none_if(self, predicate: bool) -> Option<Self> { ... }
fn with_none_if<F>(self, predicate: F) -> Option<Self>
where F: FnOnce(&Self) -> bool { ... }
}Expand description
Wrap Self in a Option based off a predicate.
Provided Methods§
Sourcefn some_if(self, predicate: bool) -> Option<Self>
fn some_if(self, predicate: bool) -> Option<Self>
Results Some(self) if the predicate returns true, or None otherwise.
Sourcefn with_some_if<F>(self, predicate: F) -> Option<Self>
fn with_some_if<F>(self, predicate: F) -> Option<Self>
Results Some(self) if the predicate returns true, or None otherwise.
Sourcefn none_if(self, predicate: bool) -> Option<Self>
fn none_if(self, predicate: bool) -> Option<Self>
Results None if the predicate returns true, or Some(self) otherwise.
Sourcefn with_none_if<F>(self, predicate: F) -> Option<Self>
fn with_none_if<F>(self, predicate: F) -> Option<Self>
Results None if the predicate returns true, or Some(self) otherwise.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.