2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-02-23 04:39:41 +00:00

Implemented Path::into_path_buf

This commit is contained in:
Wouter Geraedts 2019-10-13 18:49:52 +02:00
parent 6c6106a292
commit a57ba7ece0

View file

@ -109,6 +109,17 @@ impl Path {
fs::metadata(self).await.is_ok()
}
/// Converts a [`Box<Path>`][`Box`] into a [`PathBuf`] without copying or
/// allocating.
///
/// [`Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html
/// [`PathBuf`]: struct.PathBuf.html
pub fn into_path_buf(self: Box<Path>) -> PathBuf {
let rw = Box::into_raw(self) as *mut std::path::Path;
let inner = unsafe { Box::from_raw(rw) };
inner.into_path_buf().into()
}
/// Queries the file system to get information about a file, directory, etc.
///
/// This function will traverse symbolic links to query information about the