Auto-fixed clippy::unnecessary_map_or

This is a hacky approach, but does help a lot with the tedious fixes.

See https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_map_or

```
__CARGO_FIX_YOLO=1 cargo clippy --fix  --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::unnecessary_map_or

cargo fmt --all
```
This commit is contained in:
Yuri Astrakhan 2025-02-07 00:02:19 -05:00 committed by Olivier Goffart
parent 4ae2627ade
commit bcb2953f00
61 changed files with 145 additions and 163 deletions

View file

@ -14,7 +14,7 @@ pub(crate) fn fold_node(
let kind = node.kind();
if kind == SyntaxKind::Component && node.child_token(SyntaxKind::ColonEqual).is_some() {
let is_global =
node.child_token(SyntaxKind::Identifier).map_or(false, |t| t.text() == "global");
node.child_token(SyntaxKind::Identifier).is_some_and(|t| t.text() == "global");
if !is_global {
write!(file, "component ")?;
}
@ -22,11 +22,11 @@ pub(crate) fn fold_node(
if n.kind() == SyntaxKind::ColonEqual {
if !is_global {
let t = n.as_token().unwrap();
if t.prev_token().map_or(false, |t| t.kind() != SyntaxKind::Whitespace) {
if t.prev_token().is_some_and(|t| t.kind() != SyntaxKind::Whitespace) {
write!(file, " ")?;
}
write!(file, "inherits")?;
if t.next_token().map_or(false, |t| t.kind() != SyntaxKind::Whitespace) {
if t.next_token().is_some_and(|t| t.kind() != SyntaxKind::Whitespace) {
write!(file, " ")?;
}
}