pub struct First<A>(pub A);Expand description
A newtype wrapper whose Semigroup instance always keeps the first value.
append(First(a), First(b)) returns First(a), discarding b.
There is no Monoid instance because there is no identity element.
§Examples
use fp_library::{
functions::*,
types::First,
};
assert_eq!(append(First("hello"), First("world")), First("hello"));Tuple Fields§
§0: AThe wrapped value.
Trait Implementations§
Source§impl<A: Ord> Ord for First<A>
impl<A: Ord> Ord for First<A>
Source§impl<A: PartialOrd> PartialOrd for First<A>
impl<A: PartialOrd> PartialOrd for First<A>
Source§impl<A> Semigroup for First<A>
§Type Parameters
A: The wrapped type.
impl<A> Semigroup for First<A>
§Type Parameters
A: The wrapped type.
Source§fn append(a: Self, _b: Self) -> Self
fn append(a: Self, _b: Self) -> Self
Returns the first (leftmost) value, discarding the second.
§Type Signature
forall A. (First A, First A) -> First A
§Parameters
a: The first value (kept)._b: The second value (discarded).
§Returns
The first value.
§Examples
use fp_library::{
functions::*,
types::First,
};
assert_eq!(append(First(1), First(2)), First(1));impl<A: Copy> Copy for First<A>
impl<A: Eq> Eq for First<A>
impl<A> StructuralPartialEq for First<A>
Auto Trait Implementations§
impl<A> Freeze for First<A>where
A: Freeze,
impl<A> RefUnwindSafe for First<A>where
A: RefUnwindSafe,
impl<A> Send for First<A>where
A: Send,
impl<A> Sync for First<A>where
A: Sync,
impl<A> Unpin for First<A>where
A: Unpin,
impl<A> UnsafeUnpin for First<A>where
A: UnsafeUnpin,
impl<A> UnwindSafe for First<A>where
A: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more