File tree 1 file changed +12
-5
lines changed
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,12 @@ impl PartialOrd<AsciiString> for AsciiStr {
178
178
}
179
179
*/
180
180
181
+ impl Default for & ' static AsciiStr {
182
+ fn default ( ) -> & ' static AsciiStr {
183
+ unsafe { mem:: transmute ( "" ) }
184
+ }
185
+ }
186
+
181
187
impl ToOwned for AsciiStr {
182
188
type Owned = AsciiString ;
183
189
@@ -207,11 +213,6 @@ impl AsMut<[Ascii]> for AsciiStr {
207
213
}
208
214
}
209
215
210
- impl Default for & ' static AsciiStr {
211
- fn default ( ) -> & ' static AsciiStr {
212
- unsafe { "" . into_ascii_unchecked ( ) }
213
- }
214
- }
215
216
impl < ' a > From < & ' a [ Ascii ] > for & ' a AsciiStr {
216
217
fn from ( slice : & [ Ascii ] ) -> & AsciiStr {
217
218
unsafe { mem:: transmute ( slice) }
@@ -346,6 +347,12 @@ mod tests {
346
347
use AsciiCast ;
347
348
use super :: AsciiStr ;
348
349
350
+ #[ test]
351
+ fn default ( ) {
352
+ let default: & ' static AsciiStr = Default :: default ( ) ;
353
+ assert ! ( default . is_empty( ) ) ;
354
+ }
355
+
349
356
#[ test]
350
357
fn as_str ( ) {
351
358
let b = & [ 40_u8 , 32 , 59 ] ;
You can’t perform that action at this time.
0 commit comments