init: appease clippy

```
warning: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
   --> init/src/main.rs:127:23
    |
127 |               match (|| {
    |  _______________________^
128 | |                 let entry = entry.context("read_dir(/bin) failed")?;
129 | |                 let path = entry.path();
130 | |                 let status = std::process::Command::new(&path)
...   |
139 | |                 }
140 | |             })() {
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions
    = note: `#[warn(clippy::blocks_in_conditions)]` on by default
```

https://github.com/rust-lang/rust-clippy/pull/11853 landed in nightly.
pull/855/head
Tamir Duberstein 9 months ago
parent 890e799072
commit af935f84bf
No known key found for this signature in database

@ -123,8 +123,7 @@ fn run() -> anyhow::Result<()> {
// Iterate files in /bin. // Iterate files in /bin.
let read_dir = std::fs::read_dir("/bin").context("read_dir(/bin) failed")?; let read_dir = std::fs::read_dir("/bin").context("read_dir(/bin) failed")?;
let errors = read_dir let errors = read_dir
.filter_map(|entry| { .map(|entry| {
match (|| {
let entry = entry.context("read_dir(/bin) failed")?; let entry = entry.context("read_dir(/bin) failed")?;
let path = entry.path(); let path = entry.path();
let status = std::process::Command::new(&path) let status = std::process::Command::new(&path)
@ -137,10 +136,10 @@ fn run() -> anyhow::Result<()> {
} else { } else {
Err(anyhow::anyhow!("{} failed: {status:?}", path.display())) Err(anyhow::anyhow!("{} failed: {status:?}", path.display()))
} }
})() { })
.filter_map(|result| match result {
Ok(()) => None, Ok(()) => None,
Err(err) => Some(err), Err(err) => Some(err),
}
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
if errors.is_empty() { if errors.is_empty() {

Loading…
Cancel
Save