minor fixes to Vec docs and bounds check
This commit is contained in:
parent
80627cd3cc
commit
09164f3acf
1 changed files with 9 additions and 3 deletions
|
@ -690,7 +690,8 @@ impl<T> Vec<T> {
|
||||||
/// Panics if the number of elements in the vector overflows a `usize`.
|
/// Panics if the number of elements in the vector overflows a `usize`.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```rust
|
///
|
||||||
|
/// ```
|
||||||
/// let mut vec = vec![1, 2, 3];
|
/// let mut vec = vec![1, 2, 3];
|
||||||
/// let mut vec2 = vec![4, 5, 6];
|
/// let mut vec2 = vec![4, 5, 6];
|
||||||
/// vec.append(&mut vec2);
|
/// vec.append(&mut vec2);
|
||||||
|
@ -1002,8 +1003,13 @@ impl<T> Vec<T> {
|
||||||
///
|
///
|
||||||
/// Note that the capacity of `self` does not change.
|
/// Note that the capacity of `self` does not change.
|
||||||
///
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if `at > len`.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```rust
|
///
|
||||||
|
/// ```
|
||||||
/// let mut vec = vec![1,2,3];
|
/// let mut vec = vec![1,2,3];
|
||||||
/// let vec2 = vec.split_off(1);
|
/// let vec2 = vec.split_off(1);
|
||||||
/// assert_eq!(vec, vec![1]);
|
/// assert_eq!(vec, vec![1]);
|
||||||
|
@ -1013,7 +1019,7 @@ impl<T> Vec<T> {
|
||||||
#[unstable(feature = "collections",
|
#[unstable(feature = "collections",
|
||||||
reason = "new API, waiting for dust to settle")]
|
reason = "new API, waiting for dust to settle")]
|
||||||
pub fn split_off(&mut self, at: usize) -> Self {
|
pub fn split_off(&mut self, at: usize) -> Self {
|
||||||
assert!(at < self.len(), "`at` out of bounds");
|
assert!(at <= self.len(), "`at` out of bounds");
|
||||||
|
|
||||||
let other_len = self.len - at;
|
let other_len = self.len - at;
|
||||||
let mut other = Vec::with_capacity(other_len);
|
let mut other = Vec::with_capacity(other_len);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue