Skip to content

Commit 5235cd5

Browse files
committed
Implemented Path::display
1 parent 759e357 commit 5235cd5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/path/path.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::ffi::OsStr;
22

3-
use crate::path::{Ancestors, Components, PathBuf};
3+
use crate::path::{Ancestors, Components, Display, PathBuf};
44
use crate::{fs, io};
55

66
/// This struct is an async version of [`std::path::Path`].
@@ -106,6 +106,24 @@ impl Path {
106106
self.inner.components()
107107
}
108108

109+
/// Returns an object that implements [`Display`] for safely printing paths
110+
/// that may contain non-Unicode data.
111+
///
112+
/// [`Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
113+
///
114+
/// # Examples
115+
///
116+
/// ```
117+
/// use async_std::path::Path;
118+
///
119+
/// let path = Path::new("/tmp/foo.rs");
120+
///
121+
/// println!("{}", path.display());
122+
/// ```
123+
pub fn display(&self) -> Display<'_> {
124+
self.inner.display()
125+
}
126+
109127
/// Returns `true` if the path points at an existing entity.
110128
///
111129
/// This function will traverse symbolic links to query information about the

0 commit comments

Comments
 (0)