Skip to content

libazureinit: fix clippy warning of map_or for Rust 1.84#151

Merged
jeremycline merged 1 commit intoAzure:mainfrom
dongsupark:clippy-mapor-1.84
Jan 14, 2025
Merged

libazureinit: fix clippy warning of map_or for Rust 1.84#151
jeremycline merged 1 commit intoAzure:mainfrom
dongsupark:clippy-mapor-1.84

Conversation

@dongsupark
Copy link
Collaborator

Starting from Rust 1.84, clippy gives warning like below:

warning: this `map_or` is redundant
   --> libazureinit/src/config.rs:345:21
    |
345 |                     path.extension().map_or(false, |ext| ext == "toml")
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_some_and instead: `path.extension().is_some_and(|ext| ext == "toml")`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
    = note: `#[warn(clippy::unnecessary_map_or)]` on by default

Fix that by using is_some_and.

See also
https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-184, rust-lang/rust-clippy#11796.

Starting from Rust 1.84, clippy gives warning like below:
```
warning: this `map_or` is redundant
   --> libazureinit/src/config.rs:345:21
    |
345 |                     path.extension().map_or(false, |ext| ext == "toml")
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use is_some_and instead: `path.extension().is_some_and(|ext| ext == "toml")`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
    = note: `#[warn(clippy::unnecessary_map_or)]` on by default
```

Fix that by using `is_some_and`.

See also
https://github.com/rust-lang/rust-clippy/blob/master/CHANGELOG.md#rust-184,
rust-lang/rust-clippy#11796.
@jeremycline jeremycline merged commit e334763 into Azure:main Jan 14, 2025
5 checks passed
@dongsupark dongsupark deleted the clippy-mapor-1.84 branch January 15, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants