pub struct Dynamic;Expand description
The marker type that indicates a dynamic state for a Sector.
In this state, the sector is implemented as a dynamically resizing vector. The dynamic behavior includes growing the allocation when the number of elements reaches the current capacity, and shrinking the allocation when a significant number of elements are removed. The resizing factors are determined by the following rules:
- Growth: When pushing elements and the current length equals the capacity, the sector will grow its allocation. The new capacity is increased iteratively until it can accommodate the new length. The growth factor is determined by a manual unchecked growth function that typically doubles (or follows a similar pattern) the capacity.
- Shrinkage: When the sector’s length falls to or below half of its capacity, and the capacity is at least 4, the capacity is reduced. The new capacity is calculated as three-quarters of the old capacity plus a remainder (the modulus of the old capacity by 4). This approach helps to prevent excessive allocation while ensuring a smooth transition when elements are removed.
This state is intended for use cases where the number of elements is expected to vary significantly.
Trait Implementations§
impl DefaultDrain for Dynamic
impl DefaultIter for Dynamic
Auto Trait Implementations§
impl Freeze for Dynamic
impl RefUnwindSafe for Dynamic
impl Send for Dynamic
impl Sync for Dynamic
impl Unpin for Dynamic
impl UnwindSafe for Dynamic
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