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.
You should rarely find yourself constructing a WeightedItem by hand – instead, you’ll usually interact with existing instances from a WeightedList.
Fields§
§weight: WThe weight of the item. A non-negative number. 0 is technically valid, but not advised.
value: VThe value stored in the item.
Implementations§
Source§impl<V, W: Weight> WeightedItem<V, W>
impl<V, W: Weight> WeightedItem<V, W>
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§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
§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.
§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> From<WeightedItem<V, W>> for (W, V)
impl<V, W: Weight> From<WeightedItem<V, W>> for (W, V)
Source§fn from(item: WeightedItem<V, W>) -> Self
fn from(item: WeightedItem<V, W>) -> Self
Converts to this type from the input type.
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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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