Skip to content

Commit be12ab0

Browse files
committed
Use "capacity" as parameter name in with_capacity() methods
Closes #60271.
1 parent 597f432 commit be12ab0

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/liballoc/collections/vec_deque.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl<T> VecDeque<T> {
369369
VecDeque::with_capacity(INITIAL_CAPACITY)
370370
}
371371

372-
/// Creates an empty `VecDeque` with space for at least `n` elements.
372+
/// Creates an empty `VecDeque` with space for at least `capacity` elements.
373373
///
374374
/// # Examples
375375
///
@@ -379,10 +379,10 @@ impl<T> VecDeque<T> {
379379
/// let vector: VecDeque<u32> = VecDeque::with_capacity(10);
380380
/// ```
381381
#[stable(feature = "rust1", since = "1.0.0")]
382-
pub fn with_capacity(n: usize) -> VecDeque<T> {
382+
pub fn with_capacity(capacity: usize) -> VecDeque<T> {
383383
// +1 since the ringbuffer always leaves one space empty
384-
let cap = cmp::max(n + 1, MINIMUM_CAPACITY + 1).next_power_of_two();
385-
assert!(cap > n, "capacity overflow");
384+
let cap = cmp::max(capacity + 1, MINIMUM_CAPACITY + 1).next_power_of_two();
385+
assert!(cap > capacity, "capacity overflow");
386386

387387
VecDeque {
388388
tail: 0,

src/librustc_data_structures/bit_set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ impl<T: Idx> GrowableBitSet<T> {
607607
GrowableBitSet { bit_set: BitSet::new_empty(0) }
608608
}
609609

610-
pub fn with_capacity(bits: usize) -> GrowableBitSet<T> {
611-
GrowableBitSet { bit_set: BitSet::new_empty(bits) }
610+
pub fn with_capacity(capacity: usize) -> GrowableBitSet<T> {
611+
GrowableBitSet { bit_set: BitSet::new_empty(capacity) }
612612
}
613613

614614
/// Returns `true` if the set has changed.

src/libstd/io/buffered.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ impl<R: Read> BufReader<R> {
9292
/// }
9393
/// ```
9494
#[stable(feature = "rust1", since = "1.0.0")]
95-
pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> {
95+
pub fn with_capacity(capacity: usize, inner: R) -> BufReader<R> {
9696
unsafe {
97-
let mut buffer = Vec::with_capacity(cap);
98-
buffer.set_len(cap);
97+
let mut buffer = Vec::with_capacity(capacity);
98+
buffer.set_len(capacity);
9999
inner.initializer().initialize(&mut buffer);
100100
BufReader {
101101
inner,
@@ -477,10 +477,10 @@ impl<W: Write> BufWriter<W> {
477477
/// let mut buffer = BufWriter::with_capacity(100, stream);
478478
/// ```
479479
#[stable(feature = "rust1", since = "1.0.0")]
480-
pub fn with_capacity(cap: usize, inner: W) -> BufWriter<W> {
480+
pub fn with_capacity(capacity: usize, inner: W) -> BufWriter<W> {
481481
BufWriter {
482482
inner: Some(inner),
483-
buf: Vec::with_capacity(cap),
483+
buf: Vec::with_capacity(capacity),
484484
panicked: false,
485485
}
486486
}
@@ -851,9 +851,9 @@ impl<W: Write> LineWriter<W> {
851851
/// }
852852
/// ```
853853
#[stable(feature = "rust1", since = "1.0.0")]
854-
pub fn with_capacity(cap: usize, inner: W) -> LineWriter<W> {
854+
pub fn with_capacity(capacity: usize, inner: W) -> LineWriter<W> {
855855
LineWriter {
856-
inner: BufWriter::with_capacity(cap, inner),
856+
inner: BufWriter::with_capacity(capacity, inner),
857857
need_flush: false,
858858
}
859859
}

src/libstd/sys_common/wtf8.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ impl Wtf8Buf {
146146
Wtf8Buf { bytes: Vec::new() }
147147
}
148148

149-
/// Creates a new, empty WTF-8 string with pre-allocated capacity for `n` bytes.
149+
/// Creates a new, empty WTF-8 string with pre-allocated capacity for `capacity` bytes.
150150
#[inline]
151-
pub fn with_capacity(n: usize) -> Wtf8Buf {
152-
Wtf8Buf { bytes: Vec::with_capacity(n) }
151+
pub fn with_capacity(capacity: usize) -> Wtf8Buf {
152+
Wtf8Buf { bytes: Vec::with_capacity(capacity) }
153153
}
154154

155155
/// Creates a WTF-8 string from a UTF-8 `String`.

0 commit comments

Comments
 (0)