From 47ef222dab80059e5d8054bfcb21e6ed69fb18fb Mon Sep 17 00:00:00 2001 From: Wouter Geraedts Date: Sun, 13 Oct 2019 21:13:01 +0200 Subject: [PATCH] Implemented PathBuf::into_os_string --- src/path/pathbuf.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/path/pathbuf.rs b/src/path/pathbuf.rs index c41de4a8..5403967d 100644 --- a/src/path/pathbuf.rs +++ b/src/path/pathbuf.rs @@ -35,6 +35,22 @@ impl PathBuf { let rw = Box::into_raw(self.inner.into_boxed_path()) as *mut Path; unsafe { Box::from_raw(rw) } } + + /// Consumes the `PathBuf`, yielding its internal [`OsString`] storage. + /// + /// [`OsString`]: https://doc.rust-lang.org/std/ffi/struct.OsString.html + /// + /// # Examples + /// + /// ``` + /// use async_std::path::PathBuf; + /// + /// let p = PathBuf::from("/the/head"); + /// let os_str = p.into_os_string(); + /// ``` + pub fn into_os_string(self) -> OsString { + self.inner.into_os_string() + } } impl From for PathBuf {