前向和当前迭代器

时间:2017-05-08 00:28:29

标签: iterator rust

还有另一种写作方法吗?

fn main() {
    let mut a = [1, 2, 3, 4, 5];
    let mut iter1 = a.iter();
    let mut iter2 = a.iter().skip(1).peekable();

    while iter2.peek().is_some() {
        println!("iter1: {:?}, iter2: {:?}", iter1.next(), iter2.next());
    }
}

0 个答案:

没有答案