Skip to content

Commit f76e430

Browse files
committed
Vec: rename storage_capacity to capacity and remove the const version
1 parent 3c97d2f commit f76e430

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

src/binary_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ where
203203
/* Public API */
204204
/// Returns the capacity of the binary heap.
205205
pub fn capacity(&self) -> usize {
206-
self.data.storage_capacity()
206+
self.data.capacity()
207207
}
208208

209209
/// Drops all items from the binary heap.

src/linear_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ where
6767
/// assert_eq!(map.capacity(), 8);
6868
/// ```
6969
pub fn capacity(&self) -> usize {
70-
self.buffer.storage_capacity()
70+
self.buffer.capacity()
7171
}
7272

7373
/// Clears the map, removing all key-value pairs.

src/string/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl<S: VecStorage<u8> + ?Sized> StringInner<S> {
455455
/// ```
456456
#[inline]
457457
pub fn capacity(&self) -> usize {
458-
self.vec.storage_capacity()
458+
self.vec.capacity()
459459
}
460460

461461
/// Appends the given [`char`] to the end of this `String`.

src/vec/mod.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,6 @@ impl<T, const N: usize> Vec<T, N> {
362362
{
363363
self.as_mut_view().drain(range)
364364
}
365-
366-
/// Returns the maximum number of elements the vector can hold.
367-
///
368-
/// This method is not available on a `VecView`, use [`storage_len`](VecInner::storage_capacity) instead
369-
pub const fn capacity(&self) -> usize {
370-
self.buffer.buffer.len()
371-
}
372365
}
373366

374367
impl<T> VecView<T> {
@@ -486,7 +479,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
486479
}
487480

488481
/// Returns the maximum number of elements the vector can hold.
489-
pub fn storage_capacity(&self) -> usize {
482+
pub fn capacity(&self) -> usize {
490483
self.buffer.borrow().len()
491484
}
492485

@@ -565,7 +558,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
565558
///
566559
/// Returns back the `item` if the vector is full.
567560
pub fn push(&mut self, item: T) -> Result<(), T> {
568-
if self.len < self.storage_capacity() {
561+
if self.len < self.capacity() {
569562
unsafe { self.push_unchecked(item) }
570563
Ok(())
571564
} else {
@@ -639,7 +632,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
639632
where
640633
T: Clone,
641634
{
642-
if new_len > self.storage_capacity() {
635+
if new_len > self.capacity() {
643636
return Err(());
644637
}
645638

@@ -759,7 +752,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
759752
/// Normally, here, one would use [`clear`] instead to correctly drop
760753
/// the contents and thus not leak memory.
761754
pub unsafe fn set_len(&mut self, new_len: usize) {
762-
debug_assert!(new_len <= self.storage_capacity());
755+
debug_assert!(new_len <= self.capacity());
763756

764757
self.len = new_len
765758
}
@@ -835,7 +828,7 @@ impl<T, S: VecStorage<T> + ?Sized> VecInner<T, S> {
835828

836829
/// Returns true if the vec is full
837830
pub fn is_full(&self) -> bool {
838-
self.len == self.storage_capacity()
831+
self.len == self.capacity()
839832
}
840833

841834
/// Returns true if the vec is empty

0 commit comments

Comments
 (0)