Skip to content

Commit d0fdfbf

Browse files
committed
Auto merge of #26811 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #26464, #26789, #26800, #26806, #26808 - Failed merges: #26796
2 parents 7809e76 + d1fcb2f commit d0fdfbf

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

src/doc/reference.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,18 +3351,23 @@ heap.
33513351
A slice is a 'view' into an array. It doesn't own the data it points
33523352
to, it borrows it.
33533353

3354-
An example of each kind:
3354+
Examples:
33553355

33563356
```{rust}
3357-
let vec: Vec<i32> = vec![1, 2, 3];
3358-
let arr: [i32; 3] = [1, 2, 3];
3359-
let s: &[i32] = &vec[..];
3357+
// A stack-allocated array
3358+
let array: [i32; 3] = [1, 2, 3];
3359+
3360+
// A heap-allocated array
3361+
let vector: Vec<i32> = vec![1, 2, 3];
3362+
3363+
// A slice into an array
3364+
let slice: &[i32] = &vector[..];
33603365
```
33613366

33623367
As you can see, the `vec!` macro allows you to create a `Vec<T>` easily. The
33633368
`vec!` macro is also part of the standard library, rather than the language.
33643369

3365-
All in-bounds elements of arrays, and slices are always initialized, and access
3370+
All in-bounds elements of arrays and slices are always initialized, and access
33663371
to an array or slice is always bounds-checked.
33673372

33683373
### Structure types
@@ -3524,13 +3529,14 @@ more of the closure traits:
35243529

35253530
* `FnMut`
35263531
: The closure can be called multiple times as mutable. A closure called as
3527-
`FnMut` can mutate values from its environment. `FnMut` implies
3528-
`FnOnce`.
3532+
`FnMut` can mutate values from its environment. `FnMut` inherits from
3533+
`FnOnce` (i.e. anything implementing `FnMut` also implements `FnOnce`).
35293534

35303535
* `Fn`
35313536
: The closure can be called multiple times through a shared reference.
35323537
A closure called as `Fn` can neither move out from nor mutate values
3533-
from its environment. `Fn` implies `FnMut` and `FnOnce`.
3538+
from its environment. `Fn` inherits from `FnMut`, which itself
3539+
inherits from `FnOnce`.
35343540

35353541

35363542
### Trait objects

src/libcollections/vec_deque.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub struct VecDeque<T> {
4343
// tail and head are pointers into the buffer. Tail always points
4444
// to the first element that could be read, Head always points
4545
// to where data should be written.
46-
// If tail == head the buffer is empty. The length of the ringbuf
46+
// If tail == head the buffer is empty. The length of the ringbuffer
4747
// is defined as the distance between the two.
4848

4949
tail: usize,
@@ -309,7 +309,7 @@ impl<T> VecDeque<T> {
309309
}
310310

311311
/// Reserves capacity for at least `additional` more elements to be inserted in the given
312-
/// `Ringbuf`. The collection may reserve more space to avoid frequent reallocations.
312+
/// `VecDeque`. The collection may reserve more space to avoid frequent reallocations.
313313
///
314314
/// # Panics
315315
///
@@ -385,10 +385,10 @@ impl<T> VecDeque<T> {
385385
}
386386
}
387387

388-
/// Shrinks the capacity of the ringbuf as much as possible.
388+
/// Shrinks the capacity of the `VecDeque` as much as possible.
389389
///
390390
/// It will drop down as close as possible to the length but the allocator may still inform the
391-
/// ringbuf that there is space for a few more elements.
391+
/// `VecDeque` that there is space for a few more elements.
392392
///
393393
/// # Examples
394394
///
@@ -404,7 +404,7 @@ impl<T> VecDeque<T> {
404404
/// ```
405405
pub fn shrink_to_fit(&mut self) {
406406
// +1 since the ringbuffer always leaves one space empty
407-
// len + 1 can't overflow for an existing, well-formed ringbuf.
407+
// len + 1 can't overflow for an existing, well-formed ringbuffer.
408408
let target_cap = cmp::max(self.len() + 1, MINIMUM_CAPACITY + 1).next_power_of_two();
409409
if target_cap < self.cap {
410410
// There are three cases of interest:
@@ -472,9 +472,9 @@ impl<T> VecDeque<T> {
472472
}
473473
}
474474

475-
/// Shortens a ringbuf, dropping excess elements from the back.
475+
/// Shortens a `VecDeque`, dropping excess elements from the back.
476476
///
477-
/// If `len` is greater than the ringbuf's current length, this has no
477+
/// If `len` is greater than the `VecDeque`'s current length, this has no
478478
/// effect.
479479
///
480480
/// # Examples
@@ -858,8 +858,8 @@ impl<T> VecDeque<T> {
858858
self.tail <= self.head
859859
}
860860

861-
/// Removes an element from anywhere in the ringbuf and returns it, replacing it with the last
862-
/// element.
861+
/// Removes an element from anywhere in the `VecDeque` and returns it, replacing it with the
862+
/// last element.
863863
///
864864
/// This does not preserve ordering, but is O(1).
865865
///
@@ -892,7 +892,7 @@ impl<T> VecDeque<T> {
892892
self.pop_back()
893893
}
894894

895-
/// Removes an element from anywhere in the ringbuf and returns it,
895+
/// Removes an element from anywhere in the `VecDeque` and returns it,
896896
/// replacing it with the first element.
897897
///
898898
/// This does not preserve ordering, but is O(1).
@@ -926,13 +926,13 @@ impl<T> VecDeque<T> {
926926
self.pop_front()
927927
}
928928

929-
/// Inserts an element at position `i` within the ringbuf. Whichever
929+
/// Inserts an element at position `i` within the `VecDeque`. Whichever
930930
/// end is closer to the insertion point will be moved to make room,
931931
/// and all the affected elements will be moved to new positions.
932932
///
933933
/// # Panics
934934
///
935-
/// Panics if `i` is greater than ringbuf's length
935+
/// Panics if `i` is greater than `VecDeque`'s length
936936
///
937937
/// # Examples
938938
/// ```
@@ -1132,7 +1132,7 @@ impl<T> VecDeque<T> {
11321132
}
11331133
}
11341134

1135-
/// Removes and returns the element at position `i` from the ringbuf.
1135+
/// Removes and returns the element at position `i` from the `VecDeque`.
11361136
/// Whichever end is closer to the removal point will be moved to make
11371137
/// room, and all the affected elements will be moved to new positions.
11381138
/// Returns `None` if `i` is out of bounds.
@@ -1428,7 +1428,7 @@ impl<T> VecDeque<T> {
14281428
}
14291429

14301430
impl<T: Clone> VecDeque<T> {
1431-
/// Modifies the ringbuf in-place so that `len()` is equal to new_len,
1431+
/// Modifies the `VecDeque` in-place so that `len()` is equal to new_len,
14321432
/// either by removing excess elements or by appending copies of a value to the back.
14331433
///
14341434
/// # Examples

0 commit comments

Comments
 (0)