pub struct ReserveFraction { /* private fields */ }Expand description
An exact dyadic reserve fraction delta = 1 / 2^d.
The exponent is stored directly so capacity calculations never depend on floating-point rounding.
Implementations§
Source§impl ReserveFraction
impl ReserveFraction
Sourcepub const fn from_exponent(exponent: u32) -> Result<Self, ReserveFractionError>
pub const fn from_exponent(exponent: u32) -> Result<Self, ReserveFractionError>
Creates delta = 1 / 2^exponent.
§Errors
Returns ReserveFractionError::ExponentZero for exponent == 0,
which would represent delta = 1 rather than a fraction below one.
Sourcepub const fn floor_reserved(self, n: usize) -> usize
pub const fn floor_reserved(self, n: usize) -> usize
Returns floor(delta * n) using exact integer arithmetic.
Sourcepub const fn floor_half_reserved(self, n: usize) -> usize
pub const fn floor_half_reserved(self, n: usize) -> usize
Returns floor(delta * n / 2) using exact integer arithmetic.
Trait Implementations§
Source§impl Clone for ReserveFraction
impl Clone for ReserveFraction
Source§fn clone(&self) -> ReserveFraction
fn clone(&self) -> ReserveFraction
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ReserveFraction
Source§impl Debug for ReserveFraction
impl Debug for ReserveFraction
impl Eq for ReserveFraction
Source§impl Hash for ReserveFraction
impl Hash for ReserveFraction
Source§impl Ord for ReserveFraction
impl Ord for ReserveFraction
Source§fn cmp(&self, other: &ReserveFraction) -> Ordering
fn cmp(&self, other: &ReserveFraction) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ReserveFraction
impl PartialEq for ReserveFraction
Source§impl PartialOrd for ReserveFraction
impl PartialOrd for ReserveFraction
impl StructuralPartialEq for ReserveFraction
Auto Trait Implementations§
impl Freeze for ReserveFraction
impl RefUnwindSafe for ReserveFraction
impl Send for ReserveFraction
impl Sync for ReserveFraction
impl Unpin for ReserveFraction
impl UnsafeUnpin for ReserveFraction
impl UnwindSafe for ReserveFraction
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.