diff --git a/fuzz/src/bin/arrayish.rs b/fuzz/src/bin/arrayish.rs index 03c9ccc..2eb0652 100644 --- a/fuzz/src/bin/arrayish.rs +++ b/fuzz/src/bin/arrayish.rs @@ -25,6 +25,7 @@ arbitrary_stateful_operations! { fn extend_from_slice(&mut self, sli: &Box<[T]>); fn insert(&mut self, index: usize, item: T); fn is_empty(&self) -> bool; + fn is_full(&self) -> bool; fn len(&self) -> usize; fn pop(&mut self) -> Option; fn push(&mut self, item: T); diff --git a/fuzz/src/bin/slicevec.rs b/fuzz/src/bin/slicevec.rs index 954b0ad..15b1636 100644 --- a/fuzz/src/bin/slicevec.rs +++ b/fuzz/src/bin/slicevec.rs @@ -23,6 +23,7 @@ arbitrary_stateful_operations! { fn extend_from_slice(&mut self, sli: &Box<[T]>); fn insert(&mut self, index: usize, item: T); fn is_empty(&self) -> bool; + fn is_full(&self) -> bool; fn len(&self) -> usize; fn pop(&mut self) -> Option; fn push(&mut self, item: T); diff --git a/src/arrayvec.rs b/src/arrayvec.rs index c55796d..5986a5c 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -628,6 +628,13 @@ impl ArrayVec { self.len == 0 } + /// Checks if the length is equal to capacity. + #[inline(always)] + #[must_use] + pub fn is_full(&self) -> bool { + self.len() == self.capacity() + } + /// The length of the `ArrayVec` (in elements). #[inline(always)] #[must_use] diff --git a/src/slicevec.rs b/src/slicevec.rs index bb6b744..bc11a46 100644 --- a/src/slicevec.rs +++ b/src/slicevec.rs @@ -293,6 +293,13 @@ impl<'s, T> SliceVec<'s, T> { self.len == 0 } + /// Checks if the length is equal to capacity. + #[inline(always)] + #[must_use] + pub fn is_full(&self) -> bool { + self.len() == self.capacity() + } + /// The length of the `SliceVec` (in elements). #[inline(always)] #[must_use]