Skip to content

Commit

Permalink
fix: PathBuf's .parent() method wouldn't behave as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
Oakchris1955 committed Sep 14, 2024
1 parent dbeaf4b commit 7a2bc0c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ impl PathBuf {
pub fn parent(&self) -> PathBuf {
if self.inner.len() > 1 {
let mut pathbuf = self.clone();

if pathbuf.is_dir() {
pathbuf.inner.pop_back();
}
pathbuf.inner.back_mut().unwrap().clear();

pathbuf
} else {
PathBuf::new()
Expand Down

0 comments on commit 7a2bc0c

Please sign in to comment.