mirror of
https://github.com/helix-editor/helix.git
synced 2024-10-26 19:27:50 +03:00
Remove unnecessary unwrap
(#2599)
`strip_prefix` will itself check whether the string starts with the prefix, so the extra call to `starts_with` was unnecessary.
This commit is contained in:
parent
10415a8069
commit
89c6e8aa94
@ -5,9 +5,8 @@
|
||||
/// is available, otherwise returns the path unchanged.
|
||||
pub fn fold_home_dir(path: &Path) -> PathBuf {
|
||||
if let Ok(home) = home_dir() {
|
||||
if path.starts_with(&home) {
|
||||
// it's ok to unwrap, the path starts with home dir
|
||||
return PathBuf::from("~").join(path.strip_prefix(&home).unwrap());
|
||||
if let Ok(stripped) = path.strip_prefix(&home) {
|
||||
return PathBuf::from("~").join(stripped);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user