From 80eaa285525c1526df71a1922f5b9f6244477ed5 Mon Sep 17 00:00:00 2001 From: Wouter Geraedts Date: Sun, 13 Oct 2019 21:11:39 +0200 Subject: [PATCH] Implemented PathBuf::into_boxed_path --- src/path/pathbuf.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/path/pathbuf.rs b/src/path/pathbuf.rs index 59f2746..c41de4a 100644 --- a/src/path/pathbuf.rs +++ b/src/path/pathbuf.rs @@ -26,6 +26,15 @@ impl PathBuf { pub fn as_path(&self) -> &Path { self.inner.as_path().into() } + + /// Converts this `PathBuf` into a [boxed][`Box`] [`Path`]. + /// + /// [`Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html + /// [`Path`]: struct.Path.html + pub fn into_boxed_path(self) -> Box { + let rw = Box::into_raw(self.inner.into_boxed_path()) as *mut Path; + unsafe { Box::from_raw(rw) } + } } impl From for PathBuf {