Trait odds::vec::VecExt [] [src]

pub trait VecExt<T> {
    fn splice<R, I>(&mut self, r: R, iter: I)
    where
        I: IntoIterator<Item = T>,
        I::IntoIter: ExactSizeIterator,
        R: IndexRange
;
fn retain_mut<F>(&mut self, f: F)
    where
        F: FnMut(&mut T) -> bool
; }

Extra methods for Vec<T>

Requires feature="std"

Required Methods

Remove elements in a range, and insert from an iterator in their place.

The removed and inserted ranges don't have to match in length.

Panics if range r is out of bounds.

Panics if iterator iter is not of exact length.

Retains only the elements specified by the predicate.

In other words, remove all elements e such that f(&mut e) returns false. This method operates in place and preserves the order of the retained elements.

Examples

use odds::vec::VecExt;
let mut vec = vec![1, 2, 3, 4];
vec.retain_mut(|x| {
    let keep = *x % 2 == 0;
    *x *= 10;
    keep
});
assert_eq!(vec, [20, 40]);

Implementations on Foreign Types

impl<T> VecExt<T> for Vec<T>
[src]

Vec::splice: Remove elements in a range, and insert from an iterator in their place.

The removed and inserted ranges don't have to match in length.

Panics if range r is out of bounds.

Panics if iterator iter is not of exact length.

[src]

[src]

Implementors