Struct bitmac::grow_strategy::ForceGrowStrategy
source · [−]pub struct ForceGrowStrategy<S>(pub S);
Expand description
Increases the size of the container despite new bit state is 0
(false
).
In other words is_force_grow()
always returns true
.
Example:
use bitmac::grow_strategy::{GrowStrategy, MinimumRequiredStrategy, ForceGrowStrategy, MinimumRequiredLength};
let mut s = ForceGrowStrategy(MinimumRequiredStrategy);
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(1), 0, 0).unwrap().value(), 1);
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(2), 0, 10).unwrap().value(), 2);
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(3), 0, 23).unwrap().value(), 3);
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(4), 3, 24).unwrap().value(), 4);
assert_eq!(s.try_grow(MinimumRequiredLength::new_unchecked(5), 3, 35).unwrap().value(), 5);
assert!(s.is_force_grow());
Tuple Fields
0: S
Trait Implementations
sourceimpl<S: Clone> Clone for ForceGrowStrategy<S>
impl<S: Clone> Clone for ForceGrowStrategy<S>
sourcefn clone(&self) -> ForceGrowStrategy<S>
fn clone(&self) -> ForceGrowStrategy<S>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<S: Debug> Debug for ForceGrowStrategy<S>
impl<S: Debug> Debug for ForceGrowStrategy<S>
sourceimpl<S> GrowStrategy for ForceGrowStrategy<S> where
S: GrowStrategy,
impl<S> GrowStrategy for ForceGrowStrategy<S> where
S: GrowStrategy,
sourcefn try_grow(
&mut self,
min_req_len: MinimumRequiredLength,
old_len: usize,
bit_idx: usize
) -> Result<FinalLength, ResizeError>
fn try_grow(
&mut self,
min_req_len: MinimumRequiredLength,
old_len: usize,
bit_idx: usize
) -> Result<FinalLength, ResizeError>
Will be called when the bitmap needs to extend its container. New length always >= minimal required length of container. Read more
sourcefn is_force_grow(&self) -> bool
fn is_force_grow(&self) -> bool
Checks if the container should grow if the changing bit is exceeding container’s length
and its new state is 0
(false
) Read more
sourceimpl<S: Hash> Hash for ForceGrowStrategy<S>
impl<S: Hash> Hash for ForceGrowStrategy<S>
sourceimpl<S: PartialEq> PartialEq<ForceGrowStrategy<S>> for ForceGrowStrategy<S>
impl<S: PartialEq> PartialEq<ForceGrowStrategy<S>> for ForceGrowStrategy<S>
sourcefn eq(&self, other: &ForceGrowStrategy<S>) -> bool
fn eq(&self, other: &ForceGrowStrategy<S>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
impl<S: Copy> Copy for ForceGrowStrategy<S>
impl<S: Eq> Eq for ForceGrowStrategy<S>
impl<S> StructuralEq for ForceGrowStrategy<S>
impl<S> StructuralPartialEq for ForceGrowStrategy<S>
Auto Trait Implementations
impl<S> RefUnwindSafe for ForceGrowStrategy<S> where
S: RefUnwindSafe,
impl<S> Send for ForceGrowStrategy<S> where
S: Send,
impl<S> Sync for ForceGrowStrategy<S> where
S: Sync,
impl<S> Unpin for ForceGrowStrategy<S> where
S: Unpin,
impl<S> UnwindSafe for ForceGrowStrategy<S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more