aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
authorHugo2022-05-29 02:13:21 +0000
committerGitHub2022-05-29 02:13:21 +0000
commit89c6e8aa9419df3b7975bcae28f83e2ccc3bc318 (patch)
tree9702d46d416096207913073b98f8fdf6ffdc0ffa /helix-core/src
parent10415a80690256c2ba40e2608191b8a081c7e21b (diff)
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.
Diffstat (limited to 'helix-core/src')
-rw-r--r--helix-core/src/path.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/helix-core/src/path.rs b/helix-core/src/path.rs
index 6bf722a7..cb50e136 100644
--- a/helix-core/src/path.rs
+++ b/helix-core/src/path.rs
@@ -5,9 +5,8 @@ use std::path::{Component, Path, PathBuf};
/// 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);
}
}