File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -125,9 +125,11 @@ impl<'p> PathLike<'p> for PathDyn<'p> {
125125 }
126126
127127 fn stem ( self ) -> Option < Self :: Strand < ' p > > {
128- Some ( match self {
129- Self :: Os ( p) => p. file_stem ( ) ?. into ( ) ,
130- } )
128+ let stem = match self {
129+ Self :: Os ( p) if p. is_dir ( ) => p. file_name ( ) ,
130+ Self :: Os ( p) => p. file_stem ( ) ,
131+ } ;
132+ stem. map ( Into :: into)
131133 }
132134
133135 fn try_ends_with < ' a , T > ( self , child : T ) -> Result < bool , EndsWithError >
Original file line number Diff line number Diff line change @@ -114,7 +114,9 @@ impl<'p> PathLike<'p> for &'p std::path::Path {
114114
115115 fn parent ( self ) -> Option < Self > { self . parent ( ) }
116116
117- fn stem ( self ) -> Option < Self :: Strand < ' p > > { self . file_stem ( ) }
117+ fn stem ( self ) -> Option < Self :: Strand < ' p > > {
118+ if self . is_dir ( ) { self . file_name ( ) } else { self . file_stem ( ) }
119+ }
118120
119121 fn try_ends_with < ' a , T > ( self , child : T ) -> Result < bool , EndsWithError >
120122 where
You can’t perform that action at this time.
0 commit comments