pub trait Some {
// Required methods
fn some<T>(self, t: T) -> Option<T>;
fn some_with<T, F>(self, f: F) -> Option<T>
where F: FnOnce() -> T;
}Required Methods§
Sourcefn some<T>(self, t: T) -> Option<T>
fn some<T>(self, t: T) -> Option<T>
Returns Some(t) if the bool is true, or None otherwise.
Arguments passed to some are eagerly evaluated; if you are passing the
result of a function call, it is recommended to use
some_with, which is lazily evaluated.
§Examples
use then::Some;
assert_eq!(false.some(0), None);
assert_eq!(true.some(0), Some(0));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.