Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "capacity" as parameter name in with_capacity() methods #60316

Merged
merged 1 commit into from
Apr 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl<T> VecDeque<T> {
VecDeque::with_capacity(INITIAL_CAPACITY)
}

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

VecDeque {
tail: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_data_structures/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ impl<T: Idx> GrowableBitSet<T> {
GrowableBitSet { bit_set: BitSet::new_empty(0) }
}

pub fn with_capacity(bits: usize) -> GrowableBitSet<T> {
GrowableBitSet { bit_set: BitSet::new_empty(bits) }
pub fn with_capacity(capacity: usize) -> GrowableBitSet<T> {
GrowableBitSet { bit_set: BitSet::new_empty(capacity) }
}

/// Returns `true` if the set has changed.
Expand Down
14 changes: 7 additions & 7 deletions src/libstd/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ impl<R: Read> BufReader<R> {
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> {
pub fn with_capacity(capacity: usize, inner: R) -> BufReader<R> {
unsafe {
let mut buffer = Vec::with_capacity(cap);
buffer.set_len(cap);
let mut buffer = Vec::with_capacity(capacity);
buffer.set_len(capacity);
inner.initializer().initialize(&mut buffer);
BufReader {
inner,
Expand Down Expand Up @@ -477,10 +477,10 @@ impl<W: Write> BufWriter<W> {
/// let mut buffer = BufWriter::with_capacity(100, stream);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn with_capacity(cap: usize, inner: W) -> BufWriter<W> {
pub fn with_capacity(capacity: usize, inner: W) -> BufWriter<W> {
BufWriter {
inner: Some(inner),
buf: Vec::with_capacity(cap),
buf: Vec::with_capacity(capacity),
panicked: false,
}
}
Expand Down Expand Up @@ -851,9 +851,9 @@ impl<W: Write> LineWriter<W> {
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn with_capacity(cap: usize, inner: W) -> LineWriter<W> {
pub fn with_capacity(capacity: usize, inner: W) -> LineWriter<W> {
LineWriter {
inner: BufWriter::with_capacity(cap, inner),
inner: BufWriter::with_capacity(capacity, inner),
need_flush: false,
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/sys_common/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ impl Wtf8Buf {
Wtf8Buf { bytes: Vec::new() }
}

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

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