@@ -18,26 +18,18 @@ use std::ops::RangeTo;
18
18
use std:: ops:: RangeToInclusive ;
19
19
use std:: str;
20
20
21
+ #[ cfg( feature = "memchr" ) ]
22
+ use memchr:: memmem:: find;
23
+ #[ cfg( feature = "memchr" ) ]
24
+ use memchr:: memmem:: rfind;
25
+
21
26
use super :: imp:: raw;
22
27
use super :: iter:: Split ;
23
28
use super :: pattern:: Encoded as EncodedPattern ;
24
29
use super :: OsStrBytes ;
25
30
use super :: OsStringBytes ;
26
31
use super :: Pattern ;
27
32
28
- #[ cfg( feature = "memchr" ) ]
29
- use memchr:: memmem:: find;
30
- #[ cfg( feature = "memchr" ) ]
31
- use memchr:: memmem:: rfind;
32
-
33
- #[ cfg( feature = "print_bytes" ) ]
34
- use print_bytes:: Bytes ;
35
- #[ cfg( feature = "print_bytes" ) ]
36
- use print_bytes:: ToBytes ;
37
-
38
- #[ cfg( feature = "uniquote" ) ]
39
- use uniquote:: Quote ;
40
-
41
33
#[ cfg( not( feature = "memchr" ) ) ]
42
34
fn find ( string : & [ u8 ] , pat : & [ u8 ] ) -> Option < usize > {
43
35
for i in 0 ..=string. len ( ) . checked_sub ( pat. len ( ) ) ? {
@@ -67,9 +59,6 @@ macro_rules! impl_trim_matches {
67
59
}
68
60
69
61
let mut string = & $self. 0 ;
70
- #[ allow( unused_mut) ]
71
- #[ allow( unused_variables) ]
72
- let mut matches = 0 ;
73
62
while let Some ( substring) = string. $strip_method( pat) {
74
63
string = substring;
75
64
}
@@ -826,24 +815,6 @@ r#impl!(RangeInclusive<usize>, x, *x.start(), x.end().wrapping_add(1));
826
815
r#impl ! ( RangeTo <usize >, x, x. end) ;
827
816
r#impl ! ( RangeToInclusive <usize >, x, x. end. wrapping_add( 1 ) ) ;
828
817
829
- #[ cfg( feature = "uniquote" ) ]
830
- #[ cfg_attr( os_str_bytes_docs_rs, doc( cfg( feature = "uniquote" ) ) ) ]
831
- impl Quote for RawOsStr {
832
- #[ inline]
833
- fn escape ( & self , f : & mut uniquote:: Formatter < ' _ > ) -> uniquote:: Result {
834
- self . 0 . escape ( f)
835
- }
836
- }
837
-
838
- #[ cfg( feature = "print_bytes" ) ]
839
- #[ cfg_attr( os_str_bytes_docs_rs, doc( cfg( feature = "print_bytes" ) ) ) ]
840
- impl ToBytes for RawOsStr {
841
- #[ inline]
842
- fn to_bytes ( & self ) -> Bytes < ' _ > {
843
- self . 0 . to_bytes ( )
844
- }
845
- }
846
-
847
818
impl ToOwned for RawOsStr {
848
819
type Owned = RawOsString ;
849
820
@@ -1030,24 +1001,6 @@ r#impl!(RangeInclusive<usize>);
1030
1001
r#impl ! ( RangeTo <usize >) ;
1031
1002
r#impl ! ( RangeToInclusive <usize >) ;
1032
1003
1033
- #[ cfg( feature = "uniquote" ) ]
1034
- #[ cfg_attr( os_str_bytes_docs_rs, doc( cfg( feature = "uniquote" ) ) ) ]
1035
- impl Quote for RawOsString {
1036
- #[ inline]
1037
- fn escape ( & self , f : & mut uniquote:: Formatter < ' _ > ) -> uniquote:: Result {
1038
- ( * * self ) . escape ( f)
1039
- }
1040
- }
1041
-
1042
- #[ cfg( feature = "print_bytes" ) ]
1043
- #[ cfg_attr( os_str_bytes_docs_rs, doc( cfg( feature = "print_bytes" ) ) ) ]
1044
- impl ToBytes for RawOsString {
1045
- #[ inline]
1046
- fn to_bytes ( & self ) -> Bytes < ' _ > {
1047
- ( * * self ) . to_bytes ( )
1048
- }
1049
- }
1050
-
1051
1004
struct Buffer < ' a > ( & ' a [ u8 ] ) ;
1052
1005
1053
1006
impl Debug for Buffer < ' _ > {
@@ -1132,3 +1085,52 @@ r#impl!(&RawOsStr, String);
1132
1085
r#impl ! ( RawOsString , str ) ;
1133
1086
r#impl ! ( RawOsString , & str ) ;
1134
1087
r#impl ! ( RawOsString , String ) ;
1088
+
1089
+ #[ cfg( feature = "print_bytes" ) ]
1090
+ #[ cfg_attr( os_str_bytes_docs_rs, doc( cfg( feature = "print_bytes" ) ) ) ]
1091
+ mod print_bytes {
1092
+ use print_bytes:: Bytes ;
1093
+ use print_bytes:: ToBytes ;
1094
+
1095
+ use super :: RawOsStr ;
1096
+ use super :: RawOsString ;
1097
+
1098
+ impl ToBytes for RawOsStr {
1099
+ #[ inline]
1100
+ fn to_bytes ( & self ) -> Bytes < ' _ > {
1101
+ self . 0 . to_bytes ( )
1102
+ }
1103
+ }
1104
+
1105
+ impl ToBytes for RawOsString {
1106
+ #[ inline]
1107
+ fn to_bytes ( & self ) -> Bytes < ' _ > {
1108
+ ( * * self ) . to_bytes ( )
1109
+ }
1110
+ }
1111
+ }
1112
+
1113
+ #[ cfg( feature = "uniquote" ) ]
1114
+ #[ cfg_attr( os_str_bytes_docs_rs, doc( cfg( feature = "uniquote" ) ) ) ]
1115
+ mod uniquote {
1116
+ use uniquote:: Formatter ;
1117
+ use uniquote:: Quote ;
1118
+ use uniquote:: Result ;
1119
+
1120
+ use super :: RawOsStr ;
1121
+ use super :: RawOsString ;
1122
+
1123
+ impl Quote for RawOsStr {
1124
+ #[ inline]
1125
+ fn escape ( & self , f : & mut Formatter < ' _ > ) -> Result {
1126
+ self . 0 . escape ( f)
1127
+ }
1128
+ }
1129
+
1130
+ impl Quote for RawOsString {
1131
+ #[ inline]
1132
+ fn escape ( & self , f : & mut Formatter < ' _ > ) -> Result {
1133
+ ( * * self ) . escape ( f)
1134
+ }
1135
+ }
1136
+ }
0 commit comments