Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Jul 3, 2024
1 parent f17cb6a commit 36a704e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1577,13 +1577,12 @@ impl PathBuf {
// this is necessary for trimming the trailing slash
let end_file_name = file_name[file_name.len()..].as_ptr().addr();
let start = self.inner.as_encoded_bytes().as_ptr().addr();
let v = self.as_mut_vec();
v.truncate(end_file_name.wrapping_sub(start));
self.inner.truncate(end_file_name.wrapping_sub(start));

// append the new extension
v.reserve_exact(new.len() + 1);
v.push(b'.');
v.extend_from_slice(new);
self.inner.reserve_exact(new.len() + 1);
self.inner.push(b'.');
self.inner.extend_from_slice(new);
}

true
Expand Down

0 comments on commit 36a704e

Please sign in to comment.