Skip to content

Commit b5b2814

Browse files
authored
Merge pull request #266 from cuviper/doc-capacity
Document the lower-bound semantics of capacity
2 parents 74e14da + d3ea289 commit b5b2814

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/map.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ impl<K, V, S> IndexMap<K, V, S> {
197197
}
198198
}
199199

200+
/// Return the number of elements the map can hold without reallocating.
201+
///
202+
/// This number is a lower bound; the map might be able to hold more,
203+
/// but is guaranteed to be able to hold at least this many.
204+
///
200205
/// Computes in **O(1)** time.
201206
pub fn capacity(&self) -> usize {
202207
self.core.capacity()

src/set.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ impl<T, S> IndexSet<T, S> {
176176
}
177177
}
178178

179+
/// Return the number of elements the set can hold without reallocating.
180+
///
181+
/// This number is a lower bound; the set might be able to hold more,
182+
/// but is guaranteed to be able to hold at least this many.
183+
///
179184
/// Computes in **O(1)** time.
180185
pub fn capacity(&self) -> usize {
181186
self.map.capacity()

0 commit comments

Comments
 (0)