mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 12:55:47 +02:00
Fix clippy (#15489)
# Description There are some clippy(version 0.1.86) errors on nushell repo. This pr is trying to fix it. # User-Facing Changes Hopefully none. # Tests + Formatting NaN # After Submitting NaN
This commit is contained in:
@ -46,7 +46,7 @@ pub fn expand_ndots(path: impl AsRef<Path>) -> PathBuf {
|
||||
pub fn expand_dots(path: impl AsRef<Path>) -> PathBuf {
|
||||
// Check if the last component of the path is a normal component.
|
||||
fn last_component_is_normal(path: &Path) -> bool {
|
||||
matches!(path.components().last(), Some(Component::Normal(_)))
|
||||
matches!(path.components().next_back(), Some(Component::Normal(_)))
|
||||
}
|
||||
|
||||
let path = path.as_ref();
|
||||
@ -61,7 +61,7 @@ pub fn expand_dots(path: impl AsRef<Path>) -> PathBuf {
|
||||
// no-op
|
||||
}
|
||||
_ => {
|
||||
let prev_component = result.components().last();
|
||||
let prev_component = result.components().next_back();
|
||||
if prev_component == Some(Component::RootDir) && component == Component::ParentDir {
|
||||
continue;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ fn expand_tilde_with_home(path: impl AsRef<Path>, home: Option<PathBuf>) -> Path
|
||||
};
|
||||
}
|
||||
|
||||
let path_last_char = path.as_os_str().to_string_lossy().chars().last();
|
||||
let path_last_char = path.as_os_str().to_string_lossy().chars().next_back();
|
||||
let need_trailing_slash = path_last_char == Some('/') || path_last_char == Some('\\');
|
||||
|
||||
match home {
|
||||
@ -94,7 +94,7 @@ fn user_home_dir(username: &str) -> PathBuf {
|
||||
if !cfg!(target_os = "android")
|
||||
&& expected_path
|
||||
.components()
|
||||
.last()
|
||||
.next_back()
|
||||
.map(|last| last != Component::Normal(username.as_ref()))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
|
Reference in New Issue
Block a user