Skip to main content

Best

Struct Best 

Source
pub struct Best {
    pub addr: Addr,
    pub score: u64,
}
Expand description

The best victim seen so far in one round of sampling.

It holds an address rather than a key, which is what confines it to a single round: an address is only good until the next write, and the caller deletes the winner before it writes anything. Pool is the version that survives a round, and it pays for that by holding bytes.

This is what the random policies use, because they have no ordering for a pool to approximate and every eligible key is already the answer.

Fields§

§addr: Addr

Where the winner is, or Addr::NONE if nothing eligible turned up.

§score: u64

Its score, meaningful only against another score under the same policy.

Implementations§

Source§

impl Best

Source

pub const EMPTY: Best

Nothing yet.

Source

pub const fn is_empty(self) -> bool

Whether anything eligible has been seen.

Source

pub fn offer(&mut self, addr: Addr, score: u64)

Take this candidate if it beats what is held.

Strictly better and not as good, so a tie leaves the earlier one in place. That is what makes the random policies pick the first key sampled rather than the last, and under the other policies it means the pick does not wander between keys that are equally stale.

Trait Implementations§

Source§

impl Clone for Best

Source§

fn clone(&self) -> Best

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 Copy for Best

Source§

impl Debug for Best

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Best

§

impl RefUnwindSafe for Best

§

impl Send for Best

§

impl Sync for Best

§

impl Unpin for Best

§

impl UnsafeUnpin for Best

§

impl UnwindSafe for Best

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.