pub struct WeightedItem<V, W: Weight> {
pub weight: W,
pub value: V,
}Expand description
An item in a WeightedList, with a value of type V and a weight of numerical type W.
For consistency and layout, weight always comes before value when ordering is relevant.
Fields§
§weight: W§value: VImplementations§
Source§impl<V, W: Weight> WeightedItem<V, W>
impl<V, W: Weight> WeightedItem<V, W>
Sourcepub fn unit(value: V) -> WeightedItem<V, W>
pub fn unit(value: V) -> WeightedItem<V, W>
Construct a WeightedItem with value and a weight of 1.
Sourcepub fn new(weight: W, value: V) -> WeightedItem<V, W>
pub fn new(weight: W, value: V) -> WeightedItem<V, W>
Construct a WeightedItem with value and weight.
Sourcepub fn from((weight, value): (W, V)) -> WeightedItem<V, W>
pub fn from((weight, value): (W, V)) -> WeightedItem<V, W>
Construct a WeightedItem from a (weight, value) pair.
Trait Implementations§
Source§impl<V: Clone, W: Clone + Weight> Clone for WeightedItem<V, W>
impl<V: Clone, W: Clone + Weight> Clone for WeightedItem<V, W>
Source§fn clone(&self) -> WeightedItem<V, W>
fn clone(&self) -> WeightedItem<V, W>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<V: Display, W: Weight> Display for WeightedItem<V, W>
impl<V: Display, W: Weight> Display for WeightedItem<V, W>
Source§impl<V, W: Weight> Extend<WeightedItem<V, W>> for WeightedList<V, W>
impl<V, W: Weight> Extend<WeightedItem<V, W>> for WeightedList<V, W>
Source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = WeightedItem<V, W>>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = WeightedItem<V, W>>,
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<V, W: Weight> FromIterator<WeightedItem<V, W>> for WeightedList<V, W>
impl<V, W: Weight> FromIterator<WeightedItem<V, W>> for WeightedList<V, W>
Source§fn from_iter<I>(items: I) -> Selfwhere
I: IntoIterator<Item = WeightedItem<V, W>>,
fn from_iter<I>(items: I) -> Selfwhere
I: IntoIterator<Item = WeightedItem<V, W>>,
Creates a value from an iterator. Read more
Source§impl<V: Eq, W: Weight + Ord> Ord for WeightedItem<V, W>
impl<V: Eq, W: Weight + Ord> Ord for WeightedItem<V, W>
Source§impl<V: Eq, W: Weight> PartialOrd for WeightedItem<V, W>
impl<V: Eq, W: Weight> PartialOrd for WeightedItem<V, W>
impl<V: Eq, W: Eq + Weight> Eq for WeightedItem<V, W>
impl<V, W: Weight> StructuralPartialEq for WeightedItem<V, W>
Auto Trait Implementations§
impl<V, W> Freeze for WeightedItem<V, W>
impl<V, W> RefUnwindSafe for WeightedItem<V, W>where
W: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, W> Send for WeightedItem<V, W>
impl<V, W> Sync for WeightedItem<V, W>
impl<V, W> Unpin for WeightedItem<V, W>
impl<V, W> UnwindSafe for WeightedItem<V, W>where
W: UnwindSafe,
V: 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