11use std:: borrow:: Borrow ;
22use std:: ffi:: OsStr ;
3+ use std:: fmt;
34use std:: ops:: Deref ;
45use std:: path:: { Component , Path , PathBuf } ;
56
@@ -13,12 +14,24 @@ use crate::normalize_path;
1314#[ derive( Debug , Clone , PartialEq , Eq , Hash , Default ) ]
1415pub struct NormalizedPathBuf ( PathBuf ) ;
1516
17+ impl fmt:: Display for NormalizedPathBuf {
18+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
19+ write ! ( f, "{}" , self . display( ) )
20+ }
21+ }
22+
1623impl < P : Into < PathBuf > > From < P > for NormalizedPathBuf {
1724 fn from ( path : P ) -> Self {
1825 NormalizedPathBuf :: new ( path. into ( ) )
1926 }
2027}
2128
29+ impl AsRef < Path > for NormalizedPathBuf {
30+ fn as_ref ( & self ) -> & Path {
31+ self . 0 . as_path ( )
32+ }
33+ }
34+
2235impl Borrow < PathBuf > for NormalizedPathBuf {
2336 fn borrow ( & self ) -> & PathBuf {
2437 & self . 0
@@ -43,6 +56,14 @@ impl NormalizedPathBuf {
4356 pub fn new ( path : PathBuf ) -> Self {
4457 NormalizedPathBuf ( normalize_path ( path. canonicalize ( ) . unwrap_or ( path) ) )
4558 }
59+
60+ pub fn as_path ( & self ) -> & Path {
61+ self . 0 . as_path ( )
62+ }
63+
64+ pub fn to_path_buf ( & self ) -> PathBuf {
65+ self . 0 . clone ( )
66+ }
4667}
4768
4869#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
0 commit comments