Skip to content

Commit

Permalink
Merge pull request #29 from Qiskit/try-filter-map
Browse files Browse the repository at this point in the history
Use filter_map instead of map().filter_map()
  • Loading branch information
jlapeyre authored Jan 14, 2024
2 parents 61bd9e4 + 933ce2d commit b38f6f2
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions crates/oq3_source_file/src/source_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,19 @@ pub(crate) fn read_source_file(file_path: &Path) -> String {
}

// FIXME: prevent a file from including itself. Then there are two-file cycles, etc.
// FIXME: I want to disable filter_map_identity globally, but there is no option for clippy.toml
#[allow(clippy::filter_map_identity)]
/// Recursively parse any files `include`d in the program `syntax_ast`.
pub(crate) fn parse_included_files(syntax_ast: &ParsedSource) -> Vec<SourceFile> {
syntax_ast
.tree()
.statements()
.map(|parse_item| match parse_item {
.filter_map(|parse_item| match parse_item {
synast::Stmt::Item(synast::Item::Include(include)) => {
let file: synast::FilePath = include.file().unwrap();
let file_path = file.to_string().unwrap();
Some(parse_source_file(&PathBuf::from(file_path)))
}
_ => None,
})
.filter_map(|x| x)
.collect::<Vec<_>>()
}

Expand Down

0 comments on commit b38f6f2

Please sign in to comment.