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: STrait Implementations§
Source§impl<S: Clone> Clone for ForceGrowStrategy<S>
impl<S: Clone> Clone for ForceGrowStrategy<S>
Source§fn clone(&self) -> ForceGrowStrategy<S>
fn clone(&self) -> ForceGrowStrategy<S>
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<S: Debug> Debug for ForceGrowStrategy<S>
impl<S: Debug> Debug for ForceGrowStrategy<S>
Source§impl<S> GrowStrategy for ForceGrowStrategy<S>where
S: GrowStrategy,
impl<S> GrowStrategy for ForceGrowStrategy<S>where
S: GrowStrategy,
Source§fn 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
Source§fn 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 moreSource§impl<S: Hash> Hash for ForceGrowStrategy<S>
impl<S: Hash> Hash for ForceGrowStrategy<S>
Source§impl<S: PartialEq> PartialEq for ForceGrowStrategy<S>
impl<S: PartialEq> PartialEq for ForceGrowStrategy<S>
impl<S: Copy> Copy for ForceGrowStrategy<S>
impl<S: Eq> Eq for ForceGrowStrategy<S>
impl<S> StructuralPartialEq for ForceGrowStrategy<S>
Auto Trait Implementations§
impl<S> Freeze for ForceGrowStrategy<S>where
S: Freeze,
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§
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