mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Replace map_or(false, ..)
uses with is_some_and
and is_ok_and
(#4703)
## Summary Looks like there isn't a clippy lint for this yet.
This commit is contained in:
parent
8a2af8bc83
commit
be2a67cd9b
6 changed files with 14 additions and 21 deletions
|
@ -1201,7 +1201,7 @@ fn calculate_row_column(content: &str, position: usize) -> (usize, usize) {
|
|||
// If the next character is a newline, skip it.
|
||||
if chars
|
||||
.peek()
|
||||
.map_or(false, |&(_, next_char)| next_char == '\n')
|
||||
.is_some_and(|&(_, next_char)| next_char == '\n')
|
||||
{
|
||||
chars.next();
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> CacheControlPa
|
|||
)
|
||||
}
|
||||
let mut end = 0;
|
||||
while self.cur.get(end).copied().map_or(false, is_token_byte) {
|
||||
while self.cur.get(end).copied().is_some_and(is_token_byte) {
|
||||
end += 1;
|
||||
}
|
||||
if end == 0 {
|
||||
|
@ -240,7 +240,7 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> CacheControlPa
|
|||
///
|
||||
/// [RFC 9111 Appendix A]: https://www.rfc-editor.org/rfc/rfc9111.html#name-collected-abnf
|
||||
fn maybe_parse_equals(&mut self) -> bool {
|
||||
if self.cur.first().map_or(false, |&byte| byte == b'=') {
|
||||
if self.cur.first().is_some_and(|&byte| byte == b'=') {
|
||||
self.cur = &self.cur[1..];
|
||||
true
|
||||
} else {
|
||||
|
@ -322,7 +322,7 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> CacheControlPa
|
|||
///
|
||||
/// [RFC 9111 Appendix A]: https://www.rfc-editor.org/rfc/rfc9111.html#name-collected-abnf
|
||||
fn maybe_parse_directive_delimiter(&mut self) -> bool {
|
||||
if self.cur.first().map_or(false, |&byte| byte == b',') {
|
||||
if self.cur.first().is_some_and(|&byte| byte == b',') {
|
||||
self.cur = &self.cur[1..];
|
||||
true
|
||||
} else {
|
||||
|
@ -336,7 +336,7 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> CacheControlPa
|
|||
///
|
||||
/// [RFC 9111 Appendix A]: https://www.rfc-editor.org/rfc/rfc9111.html#name-collected-abnf
|
||||
fn skip_whitespace(&mut self) {
|
||||
while self.cur.first().map_or(false, u8::is_ascii_whitespace) {
|
||||
while self.cur.first().is_some_and(u8::is_ascii_whitespace) {
|
||||
self.cur = &self.cur[1..];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,11 +201,7 @@ pub fn directories(path: impl AsRef<Path>) -> impl Iterator<Item = PathBuf> {
|
|||
None
|
||||
}
|
||||
})
|
||||
.filter(|entry| {
|
||||
entry
|
||||
.file_type()
|
||||
.map_or(false, |file_type| file_type.is_dir())
|
||||
})
|
||||
.filter(|entry| entry.file_type().is_ok_and(|file_type| file_type.is_dir()))
|
||||
.map(|entry| entry.path())
|
||||
}
|
||||
|
||||
|
@ -228,7 +224,7 @@ pub fn symlinks(path: impl AsRef<Path>) -> impl Iterator<Item = PathBuf> {
|
|||
.filter(|entry| {
|
||||
entry
|
||||
.file_type()
|
||||
.map_or(false, |file_type| file_type.is_symlink())
|
||||
.is_ok_and(|file_type| file_type.is_symlink())
|
||||
})
|
||||
.map(|entry| entry.path())
|
||||
}
|
||||
|
@ -249,11 +245,7 @@ pub fn files(path: impl AsRef<Path>) -> impl Iterator<Item = PathBuf> {
|
|||
None
|
||||
}
|
||||
})
|
||||
.filter(|entry| {
|
||||
entry
|
||||
.file_type()
|
||||
.map_or(false, |file_type| file_type.is_file())
|
||||
})
|
||||
.filter(|entry| entry.file_type().is_ok_and(|file_type| file_type.is_file()))
|
||||
.map(|entry| entry.path())
|
||||
}
|
||||
|
||||
|
|
|
@ -52,9 +52,10 @@ impl SitePackages {
|
|||
.filter_map(|read_dir| match read_dir {
|
||||
Ok(entry) => match entry.file_type() {
|
||||
Ok(file_type) => (file_type.is_dir()
|
||||
|| entry.path().extension().map_or(false, |ext| {
|
||||
ext == "egg-link" || ext == "egg-info"
|
||||
}))
|
||||
|| entry
|
||||
.path()
|
||||
.extension()
|
||||
.is_some_and(|ext| ext == "egg-link" || ext == "egg-info"))
|
||||
.then_some(Ok(entry.path())),
|
||||
Err(err) => Some(Err(err)),
|
||||
},
|
||||
|
|
|
@ -263,7 +263,7 @@ impl InstalledToolchain {
|
|||
ToolchainRequest::ExecutableName(name) => self
|
||||
.executable()
|
||||
.file_name()
|
||||
.map_or(false, |filename| filename.to_string_lossy() == *name),
|
||||
.is_some_and(|filename| filename.to_string_lossy() == *name),
|
||||
ToolchainRequest::Implementation(implementation) => {
|
||||
implementation == self.implementation()
|
||||
}
|
||||
|
|
|
@ -425,7 +425,7 @@ impl From<ExternalCommand> for RunCommand {
|
|||
let target_path = PathBuf::from(&target);
|
||||
if target_path
|
||||
.extension()
|
||||
.map_or(false, |ext| ext.eq_ignore_ascii_case("py"))
|
||||
.is_some_and(|ext| ext.eq_ignore_ascii_case("py"))
|
||||
&& target_path.exists()
|
||||
{
|
||||
Self::Python(target_path, args.to_vec())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue