We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c7b4a96 commit cb2a656Copy full SHA for cb2a656
src/libstd/path.rs
@@ -1341,7 +1341,8 @@ impl PathBuf {
1341
#[stable(feature = "box_from_path", since = "1.17.0")]
1342
impl<'a> From<&'a Path> for Box<Path> {
1343
fn from(path: &'a Path) -> Box<Path> {
1344
- let rw = Box::into_raw(Box::from(&path.inner)) as *mut Path;
+ let boxed: Box<OsStr> = path.inner.into();
1345
+ let rw = Box::into_raw(boxed) as *mut Path;
1346
unsafe { Box::from_raw(rw) }
1347
}
1348
@@ -2313,7 +2314,8 @@ impl Path {
2313
2314
#[stable(feature = "into_boxed_path", since = "1.20.0")]
2315
pub fn into_path_buf(self: Box<Path>) -> PathBuf {
2316
let rw = Box::into_raw(self) as *mut OsStr;
- unsafe { Box::from_raw(rw) }
2317
+ let inner = unsafe { Box::from_raw(rw) };
2318
+ PathBuf { inner: OsString::from(inner) }
2319
2320
2321
0 commit comments