Skip to content

minor fixes to Vec docs and bounds check #22059

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

Merged
merged 1 commit into from
Feb 9, 2015
Merged
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
12 changes: 9 additions & 3 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,8 @@ impl<T> Vec<T> {
/// Panics if the number of elements in the vector overflows a `usize`.
///
/// # Examples
/// ```rust
///
/// ```
/// let mut vec = vec![1, 2, 3];
/// let mut vec2 = vec![4, 5, 6];
/// vec.append(&mut vec2);
Expand Down Expand Up @@ -1002,8 +1003,13 @@ impl<T> Vec<T> {
///
/// Note that the capacity of `self` does not change.
///
/// # Panics
///
/// Panics if `at > len`.
///
/// # Examples
/// ```rust
///
/// ```
/// let mut vec = vec![1,2,3];
/// let vec2 = vec.split_off(1);
/// assert_eq!(vec, vec![1]);
Expand All @@ -1013,7 +1019,7 @@ impl<T> Vec<T> {
#[unstable(feature = "collections",
reason = "new API, waiting for dust to settle")]
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 mut other = Vec::with_capacity(other_len);
Expand Down