From 32132d9fb66d95ab3bfbc5eff969a1e084310705 Mon Sep 17 00:00:00 2001 From: lukaramu Date: Mon, 17 Apr 2017 22:51:12 +0200 Subject: [PATCH] Expand std::path::Display's docs Part of #29368. * Added explanation for why the struct exists * Added link to where it is created * Added example --- src/libstd/path.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 9c8eeb0c521..ce13b57f0a2 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -2236,7 +2236,26 @@ fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { } } -/// Helper struct for safely printing paths with `format!()` and `{}` +/// Helper struct for safely printing paths with [`format!`] and `{}`. +/// +/// A [`Path`] might contain non-Unicode data. This `struct` implements the +/// [`Display`] trait in a way that mitigates that. It is created by the +/// [`display`][`Path::display`] method on [`Path`]. +/// +/// # Examples +/// +/// ``` +/// use std::path::Path; +/// +/// let path = Path::new("/tmp/foo.rs"); +/// +/// println!("{}", path.display()); +/// ``` +/// +/// [`Display`]: ../../std/fmt/trait.Display.html +/// [`format!`]: ../../std/macro.format.html +/// [`Path`]: struct.Path.html +/// [`Path::display`]: struct.Path.html#method.display #[stable(feature = "rust1", since = "1.0.0")] pub struct Display<'a> { path: &'a Path, -- GitLab