mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-02-28 06:23:08 -08:00
21 lines
382 B
Rust
21 lines
382 B
Rust
/// A helper trait for turning any type value into `Some(value)`.
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// ```
|
|
/// use rosenpass_util::option::SomeExt;
|
|
///
|
|
/// let x = 42;
|
|
/// let y = x.some();
|
|
///
|
|
/// assert_eq!(y, Some(42));
|
|
/// ```
|
|
pub trait SomeExt: Sized {
|
|
/// Wraps the calling value in `Some()`.
|
|
fn some(self) -> Option<Self> {
|
|
Some(self)
|
|
}
|
|
}
|
|
|
|
impl<T> SomeExt for T {}
|