mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
Replace .map_or(false, $closure)
with .is_some_and(closure)
(#6244)
**Summary** [Option::is_some_and](https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.is_some_and) and [Result::is_ok_and](https://doc.rust-lang.org/std/result/enum.Result.html#method.is_ok_and) are new methods is rust 1.70. I find them way more readable than `.map_or(false, ...)`. The changes are `s/.map_or(false,/.is_some_and(/g`, then manually switching to `is_ok_and` where the value is a Result rather than an Option. **Test Plan** n/a^
This commit is contained in:
parent
2e1754e5fc
commit
1df7e9831b
162 changed files with 344 additions and 476 deletions
|
@ -287,7 +287,7 @@ impl Format<IrFormatContext<'_>> for &[FormatElement] {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let is_next_text = iter.peek().map_or(false, |e| e.is_text() || e.is_space());
|
||||
let is_next_text = iter.peek().is_some_and(|e| e.is_text() || e.is_space());
|
||||
|
||||
if !is_next_text {
|
||||
write!(f, [text("\"")])?;
|
||||
|
@ -683,7 +683,7 @@ impl FormatElements for [FormatElement] {
|
|||
|
||||
fn has_label(&self, expected: LabelId) -> bool {
|
||||
self.first()
|
||||
.map_or(false, |element| element.has_label(expected))
|
||||
.is_some_and(|element| element.has_label(expected))
|
||||
}
|
||||
|
||||
fn start_tag(&self, kind: TagKind) -> Option<&Tag> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue