Skip to main content

Avg

Struct Avg 

Source
pub struct Avg<T, R> { /* private fields */ }
Expand description

Representation of a partially computed average aggregate as a (sum, count) tuple.

This struct represents the result of the linear part of the average aggregate as a (sum, count) tuple (see Stream::dyn_average). The actual average value can be obtained by dividing sum by count. Avg forms a commutative monoid with point-wise plus operation (sum1, count1) + (sum2, count2) = (sum1 + sum2, count1 + count2).

Implementations§

Source§

impl<T, R> Avg<T, R>

Source

pub const fn new(sum: T, count: R) -> Self

Create a new Avg object with the given sum and count.

Source

pub fn sum(&self) -> T
where T: Clone,

Returns the sum component of the (sum, count) tuple.

Source

pub fn count(&self) -> R
where R: Clone,

Returns the count component of the (sum, count) tuple.

Source

pub fn compute_avg(&self) -> Option<T>
where R: Clone + HasZero, T: From<R> + Div<Output = T> + Clone,

Returns sum / count or None if count is zero.

Trait Implementations§

Source§

impl<T, R> AddAssignByRef for Avg<T, R>

Source§

fn add_assign_by_ref(&mut self, rhs: &Self)

Source§

impl<T, R> AddByRef for Avg<T, R>
where T: AddByRef, R: AddByRef,

Source§

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

Source§

impl<T, R> Archive for Avg<T, R>
where <T as Archive>::Archived: Ord, <R as Archive>::Archived: Ord, T: Archive, R: Archive,

Source§

type Archived = ArchivedAvg<T, R>

The archived representation of this type. Read more
Source§

type Resolver = AvgResolver<T, R>

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
Source§

unsafe fn resolve( &self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived, )

Creates the archived version of this value at the given position and writes it to the given output. Read more
Source§

impl<T: Clone, R: Clone> Clone for Avg<T, R>

Source§

fn clone(&self) -> Avg<T, R>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, R: Debug> Debug for Avg<T, R>

Source§

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

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

impl<T: Default, R: Default> Default for Avg<T, R>

Source§

fn default() -> Avg<T, R>

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

impl<__D: Fallible + ?Sized, T, R> Deserialize<Avg<T, R>, __D> for Archived<Avg<T, R>>
where <T as Archive>::Archived: Ord, <R as Archive>::Archived: Ord, T: Archive, Archived<T>: Deserialize<T, __D>, R: Archive, Archived<R>: Deserialize<R, __D>,

Source§

fn deserialize(&self, deserializer: &mut __D) -> Result<Avg<T, R>, __D::Error>

Deserializes using the given deserializer
Source§

impl<T: Eq, R: Eq> Eq for Avg<T, R>

Source§

impl<T, R> HasZero for Avg<T, R>
where T: HasZero, R: HasZero,

Source§

fn is_zero(&self) -> bool

Source§

fn zero() -> Self

Source§

impl<T: Hash, R: Hash> Hash for Avg<T, R>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, R> IsNone for Avg<T, R>

Source§

type Inner = Avg<T, R>

Source§

fn is_none(&self) -> bool

Source§

fn unwrap_or_self(&self) -> &Self::Inner

Source§

fn from_inner(inner: Self::Inner) -> Self

Source§

fn result_to_field<E>(r: Result<Self, E>) -> Result<Self, E>
where Self: Sized,

If Self is Option<T> an Err is converted as Ok(None). For all other types the error is propagated unchanged.
Source§

impl<T, R> MulByRef<R> for Avg<T, R>
where T: MulByRef<Output = T> + From<R>, R: MulByRef<Output = R> + Clone,

Source§

type Output = Avg<T, R>

Source§

fn mul_by_ref(&self, rhs: &R) -> Avg<T, R>

Source§

impl<T, R> Neg for Avg<T, R>
where T: Neg<Output = T>, R: Neg<Output = R>,

Source§

type Output = Avg<T, R>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T, R> NegByRef for Avg<T, R>
where T: NegByRef, R: NegByRef,

Source§

fn neg_by_ref(&self) -> Self

Source§

impl<T: Ord, R: Ord> Ord for Avg<T, R>

Source§

fn cmp(&self, other: &Avg<T, R>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq, R: PartialEq> PartialEq for Avg<T, R>

Source§

fn eq(&self, other: &Avg<T, R>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<T: PartialOrd, R: PartialOrd> PartialOrd for Avg<T, R>

Source§

fn partial_cmp(&self, other: &Avg<T, R>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<__S: Fallible + ?Sized, T, R> Serialize<__S> for Avg<T, R>
where <T as Archive>::Archived: Ord, <R as Archive>::Archived: Ord, T: Serialize<__S>, R: Serialize<__S>,

Source§

fn serialize(&self, serializer: &mut __S) -> Result<Self::Resolver, __S::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
Source§

impl<T, R> SizeOf for Avg<T, R>
where T: SizeOf, R: SizeOf,

Source§

fn size_of_children(&self, context: &mut Context)

Gets the size of all “children” owned by this value, not including the size of the value itself. Read more
Source§

fn size_of(&self) -> TotalSize

Gets the total size of the current value
Source§

fn size_of_with_context(&self, context: &mut Context)

Adds the size of the current value to the given Context, including both the size of the value itself and all of its children
Source§

impl<T, R> StructuralPartialEq for Avg<T, R>

Source§

impl<T, R> SupportsRoaring for Avg<T, R>

Source§

fn supports_roaring32(&self) -> bool

Returns true if this key type can be represented in a 32-bit roaring bitmap.
Source§

fn roaring_u32_offset(&self, _min: &Self) -> Option<u32>
where Self: Sized,

Computes the u32 offset of self relative to min. Read more
Source§

fn roaring_u32_offset_dyn(&self, _min: &DynData) -> Option<u32>

Like roaring_u32_offset, but accepts min as a type-erased DynData reference.
Source§

fn roaring_u32_offset_dyn_checked(&self, min: &DynData) -> u32

Like roaring_u32_offset_dyn, but panics when the offset cannot be computed.

Auto Trait Implementations§

§

impl<T, R> Freeze for Avg<T, R>
where T: Freeze, R: Freeze,

§

impl<T, R> RefUnwindSafe for Avg<T, R>

§

impl<T, R> Send for Avg<T, R>
where T: Send, R: Send,

§

impl<T, R> Sync for Avg<T, R>
where T: Sync, R: Sync,

§

impl<T, R> Unpin for Avg<T, R>
where T: Unpin, R: Unpin,

§

impl<T, R> UnsafeUnpin for Avg<T, R>
where T: UnsafeUnpin, R: UnsafeUnpin,

§

impl<T, R> UnwindSafe for Avg<T, R>
where T: UnwindSafe, R: 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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> ArchiveUnsized for T
where T: Archive,

Source§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
Source§

type MetadataResolver = ()

The resolver for the metadata of this type. Read more
Source§

unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, )

Creates the archived version of the metadata for this value at the given position and writes it to the given output. Read more
Source§

unsafe fn resolve_unsized( &self, from: usize, to: usize, resolver: Self::MetadataResolver, out: *mut RelPtr<Self::Archived, <isize as Archive>::Archived>, )

Resolves a relative pointer to this value with the given from and to and writes it to the given output. Read more
Source§

impl<T> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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> CallHasher for T
where T: Hash + ?Sized,

Source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

Source§

impl<T> Clonable for T
where T: Clone + Default,

Source§

unsafe fn raw_clone_to(&self, dst: *mut u8)

Clone self into dst. Read more
Source§

unsafe fn raw_move_to(&mut self, dst: *mut u8)

Move the contents of self into dst, replacing the contents of self with Self::default(). Read more
Source§

unsafe fn raw_clone_from(&mut self, src: *const u8)

Clone src into self. 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> Comparable for T
where T: Ord + Eq + 'static,

Source§

unsafe fn compare(&self, other: *const u8) -> Ordering

Compare self with other. Read more
Source§

unsafe fn equal(&self, other: *const u8) -> bool

Test if self and other are equal. Read more
Source§

unsafe fn less_than(&self, other: *const u8) -> bool

Returns true iff self < other. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DBData for T

Source§

impl<T> DBWeight for T
where T: DBData + MonoidValue,

Source§

impl<T> Data for T
where T: DBData,

Source§

fn default_hash(&self) -> u64

Compute a hash of the object using default hasher and seed.
Source§

fn dyn_hash(&self, hasher: &mut dyn Hasher)

Source§

fn as_data(&self) -> &(dyn Data + 'static)

Cast any type that implements this trait to &dyn Data. Read more
Source§

fn as_data_mut(&mut self) -> &mut (dyn Data + 'static)

Cast any type that implements this trait to &mut dyn Data. Read more
Source§

impl<T> Data for T
where T: Clone + 'static,

Source§

impl<T> DeserializableDyn for T
where T: ArchivedDBData,

Source§

unsafe fn deserialize_from_bytes_with( &mut self, bytes: &[u8], pos: usize, deserializer: &mut Deserializer, )

Deserialize self from the given slice and offset. Read more
Source§

unsafe fn deserialize_from_bytes(&mut self, bytes: &[u8], pos: usize)

Deserialize self from the given slice and offset using the default deserializer configuration. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<V> Erase<dyn Data> for V

Source§

fn erase(&self) -> &(dyn Data + 'static)

Convert a reference to self into a reference to Trait.
Source§

fn erase_mut(&mut self) -> &mut (dyn Data + 'static)

Convert a mutable reference to self into a mutable reference to Trait.
Source§

fn erase_box(self: Box<V>) -> Box<dyn Data>

Convert Box<Self> into Box<Trait>.
Source§

fn erase_archived( archived: &<V as Archive>::Archived, ) -> &<dyn Data as ArchiveTrait>::Archived

Convert a reference to an archived representation of Self into a reference to a trait object of type Trait::Archived.
Source§

impl<V> Erase<dyn Weight> for V

Source§

fn erase(&self) -> &(dyn Weight + 'static)

Convert a reference to self into a reference to Trait.
Source§

fn erase_mut(&mut self) -> &mut (dyn Weight + 'static)

Convert a mutable reference to self into a mutable reference to Trait.
Source§

fn erase_box(self: Box<V>) -> Box<dyn Weight>

Convert Box<Self> into Box<Trait>.
Source§

fn erase_archived( archived: &<V as Archive>::Archived, ) -> &<dyn Weight as ArchiveTrait>::Archived

Convert a reference to an archived representation of Self into a reference to a trait object of type Trait::Archived.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GroupValue for T
where T: MonoidValue + Neg<Output = T> + NegByRef,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> MonoidValue for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Rkyv for T
where T: Archive + for<'a> Serialize<DbspSerializer<'a>> + Deserializable,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SemigroupValue for T
where T: Clone + Eq + SizeOf + AddByRef + AddAssignByRef + 'static,

Source§

impl<T> SerializeDyn for T
where T: ArchivedDBData,

Source§

fn serialize( &self, serializer: &mut DbspSerializer<'_>, ) -> Result<usize, <DbspSerializer<'_> as Fallible>::Error>

Source§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Serializer + ?Sized,

Source§

fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
Source§

fn serialize_metadata(&self, _: &mut S) -> Result<(), <S as Fallible>::Error>

Serializes the metadata for the given type.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Weight for T
where T: DBWeight,

Source§

fn set_zero(&mut self)

Set the weight to zero.
Source§

fn is_zero(&self) -> bool

Check if the weight is zero.
Source§

unsafe fn raw_add(&self, rhs: *const u8, result: *mut u8)

Add the value of rhs to self, store the result in result. Read more
Source§

unsafe fn raw_add_assign(&mut self, rhs: *const u8)

Add the value of rhs to self, store the result in self. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more