@@ -108,22 +108,20 @@ impl AsciiExt<Vec<u8>> for [u8] {
108
108
109
109
#[ inline]
110
110
fn to_ascii_uppercase ( & self ) -> Vec < u8 > {
111
- self . iter ( ) . map ( |& byte| ASCII_UPPER_MAP [ byte as uint ] ) . collect ( )
111
+ self . iter ( ) . map ( |b| b . to_ascii_uppercase ( ) ) . collect ( )
112
112
}
113
113
114
114
#[ inline]
115
115
fn to_ascii_lowercase ( & self ) -> Vec < u8 > {
116
- self . iter ( ) . map ( |& byte| ASCII_LOWER_MAP [ byte as uint ] ) . collect ( )
116
+ self . iter ( ) . map ( |b| b . to_ascii_lowercase ( ) ) . collect ( )
117
117
}
118
118
119
119
#[ inline]
120
120
fn eq_ignore_ascii_case ( & self , other : & [ u8 ] ) -> bool {
121
121
self . len ( ) == other. len ( ) &&
122
- self . iter ( ) . zip ( other. iter ( ) ) . all (
123
- |( byte_self, byte_other) | {
124
- ASCII_LOWER_MAP [ * byte_self as uint ] ==
125
- ASCII_LOWER_MAP [ * byte_other as uint ]
126
- } )
122
+ self . iter ( ) . zip ( other. iter ( ) ) . all ( |( a, b) | {
123
+ a. eq_ignore_ascii_case ( b)
124
+ } )
127
125
}
128
126
}
129
127
@@ -132,15 +130,15 @@ impl OwnedAsciiExt for Vec<u8> {
132
130
#[ inline]
133
131
fn into_ascii_uppercase ( mut self ) -> Vec < u8 > {
134
132
for byte in self . iter_mut ( ) {
135
- * byte = ASCII_UPPER_MAP [ * byte as uint ] ;
133
+ * byte = byte. to_ascii_uppercase ( ) ;
136
134
}
137
135
self
138
136
}
139
137
140
138
#[ inline]
141
139
fn into_ascii_lowercase ( mut self ) -> Vec < u8 > {
142
140
for byte in self . iter_mut ( ) {
143
- * byte = ASCII_LOWER_MAP [ * byte as uint ] ;
141
+ * byte = byte. to_ascii_lowercase ( ) ;
144
142
}
145
143
self
146
144
}
@@ -155,17 +153,17 @@ impl AsciiExt for u8 {
155
153
156
154
#[ inline]
157
155
fn to_ascii_uppercase ( & self ) -> u8 {
158
- ASCII_UPPER_MAP [ * self as uint ]
156
+ ASCII_UPPERCASE_MAP [ * self as uint ]
159
157
}
160
158
161
159
#[ inline]
162
160
fn to_ascii_lowercase ( & self ) -> u8 {
163
- ASCII_LOWER_MAP [ * self as uint ]
161
+ ASCII_LOWERCASE_MAP [ * self as uint ]
164
162
}
165
163
166
164
#[ inline]
167
165
fn eq_ignore_ascii_case ( & self , other : & u8 ) -> bool {
168
- ASCII_LOWER_MAP [ * self as uint ] == ASCII_LOWER_MAP [ * other as uint ]
166
+ self . to_ascii_lowercase ( ) == other. to_ascii_lowercase ( )
169
167
}
170
168
}
171
169
@@ -179,7 +177,7 @@ impl AsciiExt for char {
179
177
#[ inline]
180
178
fn to_ascii_uppercase ( & self ) -> char {
181
179
if self . is_ascii ( ) {
182
- ASCII_UPPER_MAP [ * self as uint ] as char
180
+ ( * self as u8 ) . to_ascii_uppercase ( ) as char
183
181
} else {
184
182
* self
185
183
}
@@ -188,7 +186,7 @@ impl AsciiExt for char {
188
186
#[ inline]
189
187
fn to_ascii_lowercase ( & self ) -> char {
190
188
if self . is_ascii ( ) {
191
- ASCII_UPPER_MAP [ * self as uint ] as char
189
+ ( * self as u8 ) . to_ascii_lowercase ( ) as char
192
190
} else {
193
191
* self
194
192
}
@@ -236,7 +234,7 @@ pub fn escape_default<F>(c: u8, mut f: F) where
236
234
}
237
235
}
238
236
239
- static ASCII_LOWER_MAP : [ u8 , ..256 ] = [
237
+ static ASCII_LOWERCASE_MAP : [ u8 , ..256 ] = [
240
238
0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 ,
241
239
0x08 , 0x09 , 0x0a , 0x0b , 0x0c , 0x0d , 0x0e , 0x0f ,
242
240
0x10 , 0x11 , 0x12 , 0x13 , 0x14 , 0x15 , 0x16 , 0x17 ,
@@ -275,7 +273,7 @@ static ASCII_LOWER_MAP: [u8, ..256] = [
275
273
0xf8 , 0xf9 , 0xfa , 0xfb , 0xfc , 0xfd , 0xfe , 0xff ,
276
274
] ;
277
275
278
- static ASCII_UPPER_MAP : [ u8 , ..256 ] = [
276
+ static ASCII_UPPERCASE_MAP : [ u8 , ..256 ] = [
279
277
0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 ,
280
278
0x08 , 0x09 , 0x0a , 0x0b , 0x0c , 0x0d , 0x0e , 0x0f ,
281
279
0x10 , 0x11 , 0x12 , 0x13 , 0x14 , 0x15 , 0x16 , 0x17 ,
0 commit comments