Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2025

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