Skip to content

Commit

Permalink
Use filter_map instead of map().filter_map()
Browse files Browse the repository at this point in the history
Closes #19
  • Loading branch information
jlapeyre committed Jan 14, 2024
1 parent 61bd9e4 commit 933ce2d
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 933ce2d

Please sign in to comment.