Skip to content

Use <[_; N]>::each_ref() when available #121

Open
@martinthomson

Description

@martinthomson

There are a few places where we construct a fixed size array of objects, then run that through map() in order to produce another fixed size array. For example:

        let bit_ctx: [_; 3] = top_ctx
            .iter()
            .map(|ctx| ctx.narrow(&format!("bit{}", bit)))
            .collect::<Vec<_>>()
            .try_into()
            .unwrap();

This is super awkward as you have to iterate the slice, map, collect into a Vec<_>, then use try_into() to maybe create the array, then unwrap that. This would be cleaner, once each_ref() becomes available in mainline rust.

        let bit_ctx = top_ctx.each_ref().map(|ctx| ctx.refine(format!("bit{}", bit)));

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