diff --git a/crates/requirements-txt/src/lib.rs b/crates/requirements-txt/src/lib.rs index dd9dafd32..34064a859 100644 --- a/crates/requirements-txt/src/lib.rs +++ b/crates/requirements-txt/src/lib.rs @@ -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(); } diff --git a/crates/uv-client/src/httpcache/control.rs b/crates/uv-client/src/httpcache/control.rs index 1e7fce2c5..365ede5b4 100644 --- a/crates/uv-client/src/httpcache/control.rs +++ b/crates/uv-client/src/httpcache/control.rs @@ -216,7 +216,7 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator> 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> 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> 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> 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..]; } } diff --git a/crates/uv-fs/src/lib.rs b/crates/uv-fs/src/lib.rs index bebeaa983..57866ee50 100644 --- a/crates/uv-fs/src/lib.rs +++ b/crates/uv-fs/src/lib.rs @@ -201,11 +201,7 @@ pub fn directories(path: impl AsRef) -> impl Iterator { 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) -> impl Iterator { .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) -> impl Iterator { 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()) } diff --git a/crates/uv-installer/src/site_packages.rs b/crates/uv-installer/src/site_packages.rs index 278b6b056..c4f18be01 100644 --- a/crates/uv-installer/src/site_packages.rs +++ b/crates/uv-installer/src/site_packages.rs @@ -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)), }, diff --git a/crates/uv-toolchain/src/managed.rs b/crates/uv-toolchain/src/managed.rs index 23c4cd6c2..58363e1ae 100644 --- a/crates/uv-toolchain/src/managed.rs +++ b/crates/uv-toolchain/src/managed.rs @@ -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() } diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index d2aa33a8f..ad57b1e80 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -425,7 +425,7 @@ impl From 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())