Skip to content

Commit 80eaa28

Browse files
committed
Implemented PathBuf::into_boxed_path
1 parent 1bd17f1 commit 80eaa28

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/path/pathbuf.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ impl PathBuf {
2626
pub fn as_path(&self) -> &Path {
2727
self.inner.as_path().into()
2828
}
29+
30+
/// Converts this `PathBuf` into a [boxed][`Box`] [`Path`].
31+
///
32+
/// [`Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html
33+
/// [`Path`]: struct.Path.html
34+
pub fn into_boxed_path(self) -> Box<Path> {
35+
let rw = Box::into_raw(self.inner.into_boxed_path()) as *mut Path;
36+
unsafe { Box::from_raw(rw) }
37+
}
2938
}
3039

3140
impl From<std::path::PathBuf> for PathBuf {

0 commit comments

Comments
 (0)