Skip to content

Commit

Permalink
Use find_map
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernQ committed Feb 28, 2024
1 parent f7029a8 commit 902d806
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,13 @@ fn run_example(workspace: &Path, mut args: RunExampleArgs) -> Result<()> {
.iter()
// Filter down the examples to only those for which the specified chip is supported:
.filter(|example| example.supports_chip(args.chip))
.find(|example| example.name() == args.example)
.map(|example| example.clone());
.find_map(|example| {
if example.name() == args.example {
Some(example.clone())
} else {
None
}
});

if let Some(example) = example {
xtask::run_example(&package_path, args.chip, target, &example)?;
Expand Down

0 comments on commit 902d806

Please sign in to comment.