pub struct Annotated<T, A> { /* private fields */ }Expand description
Annotated represents a value with an annotation.
The value will be annotated by Annotate trait.
§Examples
use semigroup::{op::Coalesce, Annotate, Annotated};
let annotated = Coalesce(Some(1)).annotated("first");
assert_eq!(annotated.value(), &Coalesce(Some(1)));
assert_eq!(annotated.annotation(), &"first");
assert_eq!(annotated, Annotated::new(Coalesce(Some(1)), "first"));Implementations§
Source§impl<T: AnnotatedSemigroup<A>, A> Annotated<T, A>
impl<T: AnnotatedSemigroup<A>, A> Annotated<T, A>
pub fn lift_unit_annotated_op( (base, unit1): (T, A), (other, unit2): (T, A), ) -> T
Source§impl<T, A> Annotated<T, A>
impl<T, A> Annotated<T, A>
pub fn new(value: T, annotation: A) -> Self
pub fn into_parts(self) -> (T, A)
pub fn parts(&self) -> (&T, &A)
pub fn parts_mut(&mut self) -> (&mut T, &mut A)
pub fn into_value(self) -> T
pub fn value(&self) -> &T
pub fn value_mut(&mut self) -> &mut T
pub fn into_annotation(self) -> A
pub fn annotation(&self) -> &A
pub fn annotation_mut(&mut self) -> &mut A
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Annotated<U, A>
pub fn map_annotation<B>(self, f: impl FnOnce(A) -> B) -> Annotated<T, B>
pub fn map_parts<U, B>( self, fv: impl FnOnce(T) -> U, fa: impl FnOnce(A) -> B, ) -> Annotated<U, B>
pub fn as_ref(&self) -> Annotated<&T, &A>
pub fn as_ref_mut(&mut self) -> Annotated<&mut T, &mut A>
pub fn as_deref(&self) -> Annotated<&T::Target, &A>where
T: Deref,
pub fn as_deref_mut(&mut self) -> Annotated<&mut T::Target, &mut A>where
T: DerefMut,
Source§impl<T, A> Annotated<&mut T, A>
impl<T, A> Annotated<&mut T, A>
pub fn value_cloned(self) -> Annotated<T, A>where
T: Clone,
Trait Implementations§
Source§impl<T: Ord, A: Ord> Ord for Annotated<T, A>
impl<T: Ord, A: Ord> Ord for Annotated<T, A>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd, A: PartialOrd> PartialOrd for Annotated<T, A>
impl<T: PartialOrd, A: PartialOrd> PartialOrd for Annotated<T, A>
Source§impl<T: AnnotatedSemigroup<A>, A> Semigroup for Annotated<T, A>
impl<T: AnnotatedSemigroup<A>, A> Semigroup for Annotated<T, A>
impl<T: Copy, A: Copy> Copy for Annotated<T, A>
impl<T: Eq, A: Eq> Eq for Annotated<T, A>
impl<T, A> StructuralPartialEq for Annotated<T, A>
Auto Trait Implementations§
impl<T, A> Freeze for Annotated<T, A>
impl<T, A> RefUnwindSafe for Annotated<T, A>where
T: RefUnwindSafe,
A: RefUnwindSafe,
impl<T, A> Send for Annotated<T, A>
impl<T, A> Sync for Annotated<T, A>
impl<T, A> Unpin for Annotated<T, A>
impl<T, A> UnwindSafe for Annotated<T, A>where
T: UnwindSafe,
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