SumMonoid

Struct SumMonoid 

Source
pub struct SumMonoid<I: SumItem>(pub I);
Expand description

Lifting is a no-op and combining is adding.

Tuple Fields§

§0: I

Implementations§

Source§

impl<I: SumItem> SumMonoid<I>

Source

pub fn sum(&self) -> &I

Trait Implementations§

Source§

impl<I: Clone + SumItem> Clone for SumMonoid<I>

Source§

fn clone(&self) -> SumMonoid<I>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I: Debug + SumItem> Debug for SumMonoid<I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I: SumItem> Default for SumMonoid<I>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, I> Deserialize<'de> for SumMonoid<I>
where I: Deserialize<'de> + SumItem,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<I: SumItem> Encodable for SumMonoid<I>

Source§

type Encoded = SumMonoid<I>

Source§

type EncodeError = Infallible

Source§

type DecodeError = Infallible

Source§

fn encode( &self, encoded: &mut Self::Encoded, ) -> Result<(), EncodeError<Self::EncodeError>>

Source§

fn decode( &mut self, encoded: &Self::Encoded, ) -> Result<(), DecodeError<Self::DecodeError>>

Source§

fn to_encoded(&self) -> Result<Self::Encoded, EncodeError<Self::EncodeError>>

Source§

fn from_encoded( encoded: &Self::Encoded, ) -> Result<Self, DecodeError<Self::DecodeError>>

Source§

fn batch_encode<Dst: AsDestMutRef<Self::Encoded>>( src: &[Self], dst: &mut [Dst], ) -> Result<(), EncodeError<Self::EncodeError>>

Source§

impl<I: SumItem> Monoid for SumMonoid<I>

Source§

type Item = I

Source§

fn neutral() -> Self

Returns a value that, when combined with some other value x, will return x.
Source§

fn lift(item: &Self::Item) -> Self

Returns a the value corresponding to the item. Ideally, collisions should be rare, i.e. they should at least not happen by accident, and probably also be hard to find on purpose.
Source§

fn combine(&self, other: &Self) -> Self

Returns the combination of two items. Not necessarily commutative. A good fingerprint monoid will make it difficult to produce the same output with different inputs (commutativity is allowed).
Source§

impl<I: PartialEq + SumItem> PartialEq for SumMonoid<I>

Source§

fn eq(&self, other: &SumMonoid<I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I> Serialize for SumMonoid<I>
where I: Serialize + SumItem,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<I: Eq + SumItem> Eq for SumMonoid<I>

Source§

impl<I: SumItem> StructuralPartialEq for SumMonoid<I>

Auto Trait Implementations§

§

impl<I> Freeze for SumMonoid<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for SumMonoid<I>
where I: RefUnwindSafe,

§

impl<I> Send for SumMonoid<I>
where I: Send,

§

impl<I> Sync for SumMonoid<I>
where I: Sync,

§

impl<I> Unpin for SumMonoid<I>
where I: Unpin,

§

impl<I> UnwindSafe for SumMonoid<I>
where I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,