pub struct First<T>(pub Option<T>);
Expand description
A semigroup over Option by returning the first value available.
let five = First::from(5);
let no_value = First(None);
let ten = First::from(10);
assert_eq!(First::from(10), ten.combine(five));
assert_eq!(First::from(10), ten.combine(no_value));
assert_eq!(First(None), no_value.combine(no_value));
Tuple Fields§
§0: Option<T>
Trait Implementations§
Source§impl<T: Ord> Ord for First<T>
impl<T: Ord> Ord for First<T>
Source§impl<T: PartialOrd> PartialOrd for First<T>
impl<T: PartialOrd> PartialOrd for First<T>
impl<T: Copy> Copy for First<T>
impl<T: Eq> Eq for First<T>
impl<T> StructuralPartialEq for First<T>
Auto Trait Implementations§
impl<T> Freeze for First<T>where
T: Freeze,
impl<T> RefUnwindSafe for First<T>where
T: RefUnwindSafe,
impl<T> Send for First<T>where
T: Send,
impl<T> Sync for First<T>where
T: Sync,
impl<T> Unpin for First<T>where
T: Unpin,
impl<T> UnwindSafe for First<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more