Skip to content

iter::fuse not behaving as expected #51119

Closed
@JEphron

Description

@JEphron

The docs led me to believe that fuse would yield items until it saw a None, and then yield only Nones. Maybe I'm misunderstanding, but

let v = vec!["0", "a", "1", "2"];
let it: Vec<Option<i32>> = v.iter().map(|x| x.parse().ok()).fuse().inspect(|x| println!("inspected {:?}",x)).collect();
println!("it:{:?}", it);

outputs

inspected Some(0)
inspected None
inspected Some(1)
inspected Some(2)
it:[Some(0), None, Some(1), Some(2)]  

whereas I'd expect to see something like it:[Some(0), None, None, None]

rustc 1.28.0-nightly (cb20f68 2018-05-21)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions