mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-09-27 12:30:35 +00:00
Vec
: rename storage_capacity
to capacity
and remove the const
version
This commit is contained in:
parent
b8a42532ce
commit
08f403fc3e
@ -203,7 +203,7 @@ where
|
||||
/* Public API */
|
||||
/// Returns the capacity of the binary heap.
|
||||
pub fn capacity(&self) -> usize {
|
||||
self.data.storage_capacity()
|
||||
self.data.capacity()
|
||||
}
|
||||
|
||||
/// Drops all items from the binary heap.
|
||||
|
@ -67,7 +67,7 @@ where
|
||||
/// assert_eq!(map.capacity(), 8);
|
||||
/// ```
|
||||
pub fn capacity(&self) -> usize {
|
||||
self.buffer.storage_capacity()
|
||||
self.buffer.capacity()
|
||||
}
|
||||
|
||||
/// Clears the map, removing all key-value pairs.
|
||||
|
@ -455,7 +455,7 @@ impl<S: VecStorage<u8> + ?Sized> StringInner<S> {
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn capacity(&self) -> usize {
|
||||
self.vec.storage_capacity()
|
||||
self.vec.capacity()
|
||||
}
|
||||
|
||||
/// Appends the given [`char`] to the end of this `String`.
|
||||
|
@ -362,13 +362,6 @@ impl<T, const N: usize> Vec<T, N> {
|
||||
{
|
||||
self.as_mut_view().drain(range)
|
||||
}
|
||||
|
||||
/// Returns the maximum number of elements the vector can hold.
|
||||
///
|
||||
/// This method is not available on a `VecView`, use [`storage_len`](VecInner::storage_capacity) instead
|
||||
pub const fn capacity(&self) -> usize {
|
||||
self.buffer.buffer.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> VecView<T> {
|
||||
@ -486,7 +479,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
|
||||
}
|
||||
|
||||
/// Returns the maximum number of elements the vector can hold.
|
||||
pub fn storage_capacity(&self) -> usize {
|
||||
pub fn capacity(&self) -> usize {
|
||||
self.buffer.borrow().len()
|
||||
}
|
||||
|
||||
@ -565,7 +558,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
|
||||
///
|
||||
/// Returns back the `item` if the vector is full.
|
||||
pub fn push(&mut self, item: T) -> Result<(), T> {
|
||||
if self.len < self.storage_capacity() {
|
||||
if self.len < self.capacity() {
|
||||
unsafe { self.push_unchecked(item) }
|
||||
Ok(())
|
||||
} else {
|
||||
@ -639,7 +632,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
if new_len > self.storage_capacity() {
|
||||
if new_len > self.capacity() {
|
||||
return Err(());
|
||||
}
|
||||
|
||||
@ -759,7 +752,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
|
||||
/// Normally, here, one would use [`clear`] instead to correctly drop
|
||||
/// the contents and thus not leak memory.
|
||||
pub unsafe fn set_len(&mut self, new_len: usize) {
|
||||
debug_assert!(new_len <= self.storage_capacity());
|
||||
debug_assert!(new_len <= self.capacity());
|
||||
|
||||
self.len = new_len
|
||||
}
|
||||
@ -835,7 +828,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
|
||||
|
||||
/// Returns true if the vec is full
|
||||
pub fn is_full(&self) -> bool {
|
||||
self.len == self.storage_capacity()
|
||||
self.len == self.capacity()
|
||||
}
|
||||
|
||||
/// Returns true if the vec is empty
|
||||
|
Loading…
x
Reference in New Issue
Block a user