pub struct Last<A>(pub A);Expand description
A newtype wrapper whose Semigroup instance always keeps the last value.
append(Last(a), Last(b)) returns Last(b), discarding a.
There is no Monoid instance because there is no identity element.
§Examples
use fp_library::{
functions::*,
types::Last,
};
assert_eq!(append(Last("hello"), Last("world")), Last("world"));Tuple Fields§
§0: AThe wrapped value.
Trait Implementations§
Source§impl<A: Ord> Ord for Last<A>
impl<A: Ord> Ord for Last<A>
Source§impl<A: PartialOrd> PartialOrd for Last<A>
impl<A: PartialOrd> PartialOrd for Last<A>
Source§impl<A> Semigroup for Last<A>
§Type Parameters
A: The wrapped type.
impl<A> Semigroup for Last<A>
§Type Parameters
A: The wrapped type.
Source§fn append(_a: Self, b: Self) -> Self
fn append(_a: Self, b: Self) -> Self
Returns the last (rightmost) value, discarding the first.
§Type Signature
forall A. (Last A, Last A) -> Last A
§Parameters
_a: The first value (discarded).b: The second value (kept).
§Returns
The second value.
§Examples
use fp_library::{
functions::*,
types::Last,
};
assert_eq!(append(Last(1), Last(2)), Last(2));impl<A: Copy> Copy for Last<A>
impl<A: Eq> Eq for Last<A>
impl<A> StructuralPartialEq for Last<A>
Auto Trait Implementations§
impl<A> Freeze for Last<A>where
A: Freeze,
impl<A> RefUnwindSafe for Last<A>where
A: RefUnwindSafe,
impl<A> Send for Last<A>where
A: Send,
impl<A> Sync for Last<A>where
A: Sync,
impl<A> Unpin for Last<A>where
A: Unpin,
impl<A> UnsafeUnpin for Last<A>where
A: UnsafeUnpin,
impl<A> UnwindSafe for Last<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