@@ -42,11 +42,26 @@ pub fn precompose_path(path: Cow<'_, Path>) -> Cow<'_, Path> {
42
42
/// Return the precomposed version of `name`, or `name` itself if it contained illformed unicode,
43
43
/// or if the unicode version didn't contains decomposed unicode.
44
44
/// Otherwise, similar to [`precompose()`]
45
- pub fn precompose_os_string ( path : Cow < ' _ , OsStr > ) -> Cow < ' _ , OsStr > {
46
- match path . to_str ( ) {
47
- None => path ,
45
+ pub fn precompose_os_string ( name : Cow < ' _ , OsStr > ) -> Cow < ' _ , OsStr > {
46
+ match name . to_str ( ) {
47
+ None => name ,
48
48
Some ( maybe_decomposed) => match precompose ( maybe_decomposed. into ( ) ) {
49
- Cow :: Borrowed ( _) => path,
49
+ Cow :: Borrowed ( _) => name,
50
+ Cow :: Owned ( precomposed) => Cow :: Owned ( precomposed. into ( ) ) ,
51
+ } ,
52
+ }
53
+ }
54
+
55
+ /// Return the precomposed version of `s`, or `s` itself if it contained illformed unicode,
56
+ /// or if the unicode version didn't contains decomposed unicode.
57
+ /// Otherwise, similar to [`precompose()`]
58
+ #[ cfg( feature = "bstr" ) ]
59
+ pub fn precompose_bstr ( s : Cow < ' _ , bstr:: BStr > ) -> Cow < ' _ , bstr:: BStr > {
60
+ use bstr:: ByteSlice ;
61
+ match s. to_str ( ) . ok ( ) {
62
+ None => s,
63
+ Some ( maybe_decomposed) => match precompose ( maybe_decomposed. into ( ) ) {
64
+ Cow :: Borrowed ( _) => s,
50
65
Cow :: Owned ( precomposed) => Cow :: Owned ( precomposed. into ( ) ) ,
51
66
} ,
52
67
}
0 commit comments