Skip to content

Commit

Permalink
Merge pull request #46 from Zoxc/has_cap
Browse files Browse the repository at this point in the history
Add `has_capacity` as a proxy for `is_singleton`
  • Loading branch information
Gankra authored Dec 3, 2023
2 parents b9e3de0 + d9c0cd6 commit 1b79c91
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,11 @@ impl<T> ThinVec<T> {
self.header().cap()
}

/// Returns `true` if the vector has the capacity to hold any element.
pub fn has_capacity(&self) -> bool {
!self.is_singleton()
}

/// Forces the length of the vector to `new_len`.
///
/// This is a low-level operation that maintains none of the normal
Expand Down

0 comments on commit 1b79c91

Please sign in to comment.