slicetools 0.3.0

Add extra iterators to slices.
Documentation
use super::PairsMut;
use ::StreamerMut;

#[test]
fn empty_slice() {
    let input: &mut [i32] = &mut [];
    let mut it = PairsMut::new(input);
    
    assert!(it.next().is_none());
}

#[test]
fn slice_with_1_item() {
    let input = &mut [0];
    let mut it = PairsMut::new(input);
    
    assert_eq!(it.next(), None);
}

#[test]
fn slice_with_2_items() {
    let input = &mut [0, 1];
    let mut it = PairsMut::new(input);
    
    assert_eq!(it.next(), Some((&mut 0, &mut 1)));
    assert_eq!(it.next(), None);
}

#[test]
fn slice_with_3_items() {
    let input = &mut [0, 1, 2];
    let mut it = PairsMut::new(input);
    
    assert_eq!(it.next(), Some((&mut 0, &mut 1)));
    assert_eq!(it.next(), Some((&mut 0, &mut 2)));
    assert_eq!(it.next(), Some((&mut 1, &mut 2)));
    assert_eq!(it.next(), None);
}

#[test]
fn simple_algorith() {
    let mut v = vec![1, 2, 3, 4];
    {
        let mut it = PairsMut::new(&mut v);
        
        while let Some((a, b)) = it.next() {
            if *b > *a {
                *a += 1;
            }
        }
    }
    assert_eq!(v, &[4, 4, 4, 4]);
}