Skip to content

Commit

Permalink
Allow index of split_off to equal length of vector
Browse files Browse the repository at this point in the history
This makes it similar to the primitive slice `split_at` from the
standard library (see
https://doc.rust-lang.org/std/primitive.slice.html#method.split_at).
  • Loading branch information
bbc2 authored and bodil committed Aug 2, 2018
1 parent 33418b8 commit b314454
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ impl<A: Clone> Vector<A> {
/// # }
/// ```
pub fn split_off(&mut self, index: usize) -> Self {
assert!(index < self.len());
assert!(index <= self.len());

let mut local_index = index;

Expand Down Expand Up @@ -1832,7 +1832,7 @@ mod test {

#[test]
fn split(ref vec in vec(i32::ANY, 1..2000), split_pos in usize::ANY) {
let split_index = split_pos % vec.len();
let split_index = split_pos % (vec.len() + 1);
let mut left = Vector::from_iter(vec.iter().cloned());
let right = left.split_off(split_index);
assert_eq!(left.len(), split_index);
Expand Down

0 comments on commit b314454

Please sign in to comment.