@@ -129,7 +129,7 @@ impl<'a> AssetPath<'a> {
129
129
Some ( source) => AssetSourceId :: Name ( CowArc :: Borrowed ( source) ) ,
130
130
None => AssetSourceId :: Default ,
131
131
} ,
132
- path : CowArc :: Borrowed ( path) . normalize_cow_path ( ) ,
132
+ path : maybe_normalize_path :: < ' a , _ > ( CowArc :: Borrowed ( path) ) ,
133
133
label : label. map ( CowArc :: Borrowed ) ,
134
134
} )
135
135
}
@@ -227,7 +227,7 @@ impl<'a> AssetPath<'a> {
227
227
#[ inline]
228
228
pub fn from_path_buf ( path_buf : PathBuf ) -> AssetPath < ' a > {
229
229
AssetPath {
230
- path : CowArc :: < ' _ , Path > :: Owned ( path_buf. into ( ) ) . normalize_cow_path ( ) ,
230
+ path : maybe_normalize_path ( CowArc :: < ' _ , Path > :: Owned ( path_buf. into ( ) ) ) ,
231
231
source : AssetSourceId :: Default ,
232
232
label : None ,
233
233
}
@@ -237,7 +237,7 @@ impl<'a> AssetPath<'a> {
237
237
#[ inline]
238
238
pub fn from_path ( path : & ' a Path ) -> AssetPath < ' a > {
239
239
AssetPath {
240
- path : CowArc :: Borrowed ( path) . normalize_cow_path ( ) ,
240
+ path : maybe_normalize_path ( CowArc :: Borrowed ( path) ) ,
241
241
source : AssetSourceId :: Default ,
242
242
label : None ,
243
243
}
@@ -346,7 +346,7 @@ impl<'a> AssetPath<'a> {
346
346
pub fn normalized ( self ) -> AssetPath < ' a > {
347
347
AssetPath {
348
348
source : self . source ,
349
- path : self . path . normalize_cow_path ( ) ,
349
+ path : maybe_normalize_path ( self . path ) ,
350
350
label : self . label ,
351
351
}
352
352
}
@@ -556,7 +556,7 @@ impl From<&'static str> for AssetPath<'static> {
556
556
let ( source, path, label) = Self :: parse_internal ( asset_path) . unwrap ( ) ;
557
557
AssetPath {
558
558
source : source. into ( ) ,
559
- path : CowArc :: Static ( path) . normalize_cow_path ( ) ,
559
+ path : maybe_normalize_path ( CowArc :: Static ( path) ) ,
560
560
label : label. map ( CowArc :: Static ) ,
561
561
}
562
562
}
@@ -581,7 +581,7 @@ impl From<&'static Path> for AssetPath<'static> {
581
581
fn from ( path : & ' static Path ) -> Self {
582
582
Self {
583
583
source : AssetSourceId :: Default ,
584
- path : CowArc :: Static ( path) . normalize_cow_path ( ) ,
584
+ path : maybe_normalize_path ( CowArc :: Static ( path) ) ,
585
585
label : None ,
586
586
}
587
587
}
@@ -593,7 +593,7 @@ impl From<PathBuf> for AssetPath<'static> {
593
593
let path: CowArc < ' _ , Path > = path. into ( ) ;
594
594
Self {
595
595
source : AssetSourceId :: Default ,
596
- path : path . normalize_cow_path ( ) ,
596
+ path : maybe_normalize_path ( path ) ,
597
597
label : None ,
598
598
}
599
599
}
@@ -705,19 +705,9 @@ pub(crate) fn maybe_normalize_path<'a, P: AsRef<Path> + Into<CowArc<'a, Path>> +
705
705
}
706
706
}
707
707
708
- trait NormalizeCowPath {
709
- fn normalize_cow_path ( self ) -> Self ;
710
- }
711
-
712
- impl NormalizeCowPath for CowArc < ' _ , Path > {
713
- fn normalize_cow_path ( self ) -> Self {
714
- maybe_normalize_path ( self )
715
- }
716
- }
717
-
718
708
#[ cfg( test) ]
719
709
mod tests {
720
- use crate :: { path:: NormalizeCowPath , AssetPath } ;
710
+ use crate :: { path:: maybe_normalize_path , AssetPath } ;
721
711
use alloc:: string:: ToString ;
722
712
use atomicow:: CowArc ;
723
713
use std:: path:: Path ;
@@ -727,12 +717,12 @@ mod tests {
727
717
let path: CowArc < Path > = "a/../a/b" . into ( ) ;
728
718
729
719
assert_eq ! (
730
- path . normalize_cow_path ( ) ,
720
+ maybe_normalize_path ( path ) ,
731
721
CowArc :: Owned ( Path :: new( "a/b" ) . into( ) )
732
722
) ;
733
723
734
724
let path: CowArc < Path > = "a/b" . into ( ) ;
735
- assert_eq ! ( path . normalize_cow_path ( ) , CowArc :: Static ( Path :: new( "a/b" ) ) ) ;
725
+ assert_eq ! ( maybe_normalize_path ( path ) , CowArc :: Static ( Path :: new( "a/b" ) ) ) ;
736
726
737
727
let path = "a/b" ;
738
728
let donor = 3 ;
@@ -741,7 +731,7 @@ mod tests {
741
731
}
742
732
let path = CowArc :: < Path > :: Borrowed ( steal_lifetime ( & donor, Path :: new ( path) ) ) ;
743
733
assert_eq ! (
744
- path . normalize_cow_path ( ) ,
734
+ maybe_normalize_path ( path ) ,
745
735
CowArc :: Borrowed ( Path :: new( "a/b" ) )
746
736
) ;
747
737
}
0 commit comments