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:
parent
6c6106a292
commit
a57ba7ece0
1 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue