Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e54681a

Browse files
committed
refactor
1 parent ac89d38 commit e54681a

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

git-url/src/expand_path.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ impl Url {
2323
&self,
2424
home_for_user: impl FnOnce(&UserExpansion) -> Option<PathBuf>,
2525
) -> Result<PathBuf, Error> {
26-
fn join_relative(mut base: PathBuf, path: &Path) -> PathBuf {
27-
base.extend(path.components().skip(1));
28-
base
26+
fn make_relative(path: &Path) -> PathBuf {
27+
path.components().skip(1).collect()
2928
}
3029
let path = self.path.to_path()?;
3130
Ok(match self.expansion.as_ref() {
32-
Some(user) => join_relative(home_for_user(user).ok_or(Error::MissingHome)?, path),
31+
Some(user) => home_for_user(user).ok_or(Error::MissingHome)?.join(make_relative(path)),
3332
None => self.path.to_path()?.into(),
3433
})
3534
}

0 commit comments

Comments
 (0)