mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +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
|
@ -150,8 +150,8 @@ impl<'a> Definitions<'a> {
|
|||
MemberKind::Class => {
|
||||
let parent = &definitions[member.parent];
|
||||
if parent.visibility.is_private()
|
||||
|| exports.map_or(false, |exports| {
|
||||
member.name().map_or(false, |name| !exports.contains(&name))
|
||||
|| exports.is_some_and(|exports| {
|
||||
member.name().is_some_and(|name| !exports.contains(&name))
|
||||
})
|
||||
{
|
||||
Visibility::Private
|
||||
|
@ -180,8 +180,8 @@ impl<'a> Definitions<'a> {
|
|||
MemberKind::Function => {
|
||||
let parent = &definitions[member.parent];
|
||||
if parent.visibility.is_private()
|
||||
|| exports.map_or(false, |exports| {
|
||||
member.name().map_or(false, |name| !exports.contains(&name))
|
||||
|| exports.is_some_and(|exports| {
|
||||
member.name().is_some_and(|name| !exports.contains(&name))
|
||||
})
|
||||
{
|
||||
Visibility::Private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue