rust-lang / rustc_codegen_gcc

libgccjit AOT codegen for rustc
Apache License 2.0
905 stars 60 forks source link

Improve iterator for files suppression #395

Closed GuillaumeGomez closed 6 months ago

GuillaumeGomez commented 8 months ago

In build_system/test.rs we currently have:

        for path in files
            .iter()
            .enumerate()
            .filter(|(pos, _)| *pos < start || *pos >= end)
            .map(|(_, path)| path)
        {
            remove_file(&rust_path.join(path))?;
        }

It would probably be simpler to use skip and take.

Liewyec commented 7 months ago

Hello, I tried to look at this and thought that it should be simple. but can you actually use skip and take here? The filter yields some element from the beginning and possibly some from the end, I cannot think of a combination of skip and take that would achieve the same result.