Make ModPath display escaped path

This commit is contained in:
Ryo Yoshida 2022-08-11 02:17:15 +09:00
parent 8fe73a2240
commit 018266a7ff
No known key found for this signature in database
GPG key ID: E25698A930586171
4 changed files with 9 additions and 9 deletions

View file

@ -22,7 +22,7 @@ pub struct ModPath {
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct EscapedModPath<'a>(&'a ModPath);
pub struct UnescapedModPath<'a>(&'a ModPath);
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum PathKind {
@ -102,8 +102,8 @@ impl ModPath {
}
}
pub fn escaped(&self) -> EscapedModPath<'_> {
EscapedModPath(self)
pub fn unescaped(&self) -> UnescapedModPath<'_> {
UnescapedModPath(self)
}
fn _fmt(&self, f: &mut fmt::Formatter<'_>, escaped: bool) -> fmt::Result {
@ -145,13 +145,13 @@ impl ModPath {
impl Display for ModPath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self._fmt(f, false)
self._fmt(f, true)
}
}
impl<'a> Display for EscapedModPath<'a> {
impl<'a> Display for UnescapedModPath<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0._fmt(f, true)
self.0._fmt(f, false)
}
}