mirror of
https://github.com/async-rs/async-std.git
synced 2025-03-31 13:36:41 +00:00
Implemented Path::display
This commit is contained in:
parent
759e357bea
commit
5235cd58be
1 changed files with 19 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::ffi::OsStr;
|
||||
|
||||
use crate::path::{Ancestors, Components, PathBuf};
|
||||
use crate::path::{Ancestors, Components, Display, PathBuf};
|
||||
use crate::{fs, io};
|
||||
|
||||
/// This struct is an async version of [`std::path::Path`].
|
||||
|
@ -106,6 +106,24 @@ impl Path {
|
|||
self.inner.components()
|
||||
}
|
||||
|
||||
/// Returns an object that implements [`Display`] for safely printing paths
|
||||
/// that may contain non-Unicode data.
|
||||
///
|
||||
/// [`Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use async_std::path::Path;
|
||||
///
|
||||
/// let path = Path::new("/tmp/foo.rs");
|
||||
///
|
||||
/// println!("{}", path.display());
|
||||
/// ```
|
||||
pub fn display(&self) -> Display<'_> {
|
||||
self.inner.display()
|
||||
}
|
||||
|
||||
/// Returns `true` if the path points at an existing entity.
|
||||
///
|
||||
/// This function will traverse symbolic links to query information about the
|
||||
|
|
Loading…
Reference in a new issue