Skip to content

Commit

Permalink
Delete PathDisplay type
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 2, 2023
1 parent bd640d1 commit bb49bb3
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/display.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fmt::{self, Display};
use std::path::{Path, PathBuf};
use std::fmt::Display;
use std::path::{self, Path, PathBuf};

#[doc(hidden)]
pub trait AsDisplay<'a> {
Expand All @@ -20,29 +20,19 @@ where
}

impl<'a> AsDisplay<'a> for Path {
type Target = PathDisplay<'a>;
type Target = path::Display<'a>;

#[inline]
fn as_display(&'a self) -> Self::Target {
PathDisplay(self)
self.display()
}
}

impl<'a> AsDisplay<'a> for PathBuf {
type Target = PathDisplay<'a>;
type Target = path::Display<'a>;

#[inline]
fn as_display(&'a self) -> Self::Target {
PathDisplay(self.as_path())
}
}

#[doc(hidden)]
pub struct PathDisplay<'a>(&'a Path);

impl<'a> Display for PathDisplay<'a> {
#[inline]
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
self.0.display().fmt(formatter)
self.display()
}
}

0 comments on commit bb49bb3

Please sign in to comment.