diff options
Diffstat (limited to 'vendor/globset/src/pathutil.rs')
-rw-r--r-- | vendor/globset/src/pathutil.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/vendor/globset/src/pathutil.rs b/vendor/globset/src/pathutil.rs index 522df3401..8488e74f2 100644 --- a/vendor/globset/src/pathutil.rs +++ b/vendor/globset/src/pathutil.rs @@ -4,12 +4,10 @@ use bstr::{ByteSlice, ByteVec}; /// The final component of the path, if it is a normal file. /// -/// If the path terminates in ., .., or consists solely of a root of prefix, -/// file_name will return None. -pub fn file_name<'a>(path: &Cow<'a, [u8]>) -> Option<Cow<'a, [u8]>> { - if path.is_empty() { - return None; - } else if path.last_byte() == Some(b'.') { +/// If the path terminates in `.`, `..`, or consists solely of a root of +/// prefix, file_name will return None. +pub(crate) fn file_name<'a>(path: &Cow<'a, [u8]>) -> Option<Cow<'a, [u8]>> { + if path.last_byte().map_or(true, |b| b == b'.') { return None; } let last_slash = path.rfind_byte(b'/').map(|i| i + 1).unwrap_or(0); @@ -39,7 +37,9 @@ pub fn file_name<'a>(path: &Cow<'a, [u8]>) -> Option<Cow<'a, [u8]>> { /// a pattern like `*.rs` is obviously trying to match files with a `rs` /// extension, but it also matches files like `.rs`, which doesn't have an /// extension according to std::path::Path::extension. -pub fn file_name_ext<'a>(name: &Cow<'a, [u8]>) -> Option<Cow<'a, [u8]>> { +pub(crate) fn file_name_ext<'a>( + name: &Cow<'a, [u8]>, +) -> Option<Cow<'a, [u8]>> { if name.is_empty() { return None; } @@ -60,7 +60,7 @@ pub fn file_name_ext<'a>(name: &Cow<'a, [u8]>) -> Option<Cow<'a, [u8]>> { /// Normalizes a path to use `/` as a separator everywhere, even on platforms /// that recognize other characters as separators. #[cfg(unix)] -pub fn normalize_path(path: Cow<'_, [u8]>) -> Cow<'_, [u8]> { +pub(crate) fn normalize_path(path: Cow<'_, [u8]>) -> Cow<'_, [u8]> { // UNIX only uses /, so we're good. path } @@ -68,11 +68,11 @@ pub fn normalize_path(path: Cow<'_, [u8]>) -> Cow<'_, [u8]> { /// Normalizes a path to use `/` as a separator everywhere, even on platforms /// that recognize other characters as separators. #[cfg(not(unix))] -pub fn normalize_path(mut path: Cow<[u8]>) -> Cow<[u8]> { +pub(crate) fn normalize_path(mut path: Cow<[u8]>) -> Cow<[u8]> { use std::path::is_separator; for i in 0..path.len() { - if path[i] == b'/' || !is_separator(path[i] as char) { + if path[i] == b'/' || !is_separator(char::from(path[i])) { continue; } path.to_mut()[i] = b'/'; |