remove references to PathBuf::as_mut_vec in PathBuf::_set_extension · model-checking/verify-rust-std@7cec6ef (original) (raw)

Original file line number Diff line number Diff line change
@@ -1511,15 +1511,14 @@ impl PathBuf {
1511 1511 // truncate until right after the file stem
1512 1512 let end_file_stem = file_stem[file_stem.len()..].as_ptr().addr();
1513 1513 let start = self.inner.as_encoded_bytes().as_ptr().addr();
1514 -let v = self.as_mut_vec();
1515 - v.truncate(end_file_stem.wrapping_sub(start));
1514 +self.inner.truncate(end_file_stem.wrapping_sub(start));
1516 1515
1517 1516 // add the new extension, if any
1518 -let new = extension.as_encoded_bytes();
1517 +let new = extension;
1519 1518 if !new.is_empty() {
1520 -v.reserve_exact(new.len() + 1);
1521 -v.push(b'.');
1522 -v.extend_from_slice(new);
1519 +self.inner.reserve_exact(new.len() + 1);
1520 +self.inner.push(OsStr::new("."));
1521 +self.inner.push(new);
1523 1522 }
1524 1523
1525 1524 true