@@ -22,7 +22,7 @@ use encoding::{self, DecoderTrap, EncoderTrap, EncodingRef};
22
22
23
23
use crate :: buf32:: { self , Buf32 } ;
24
24
use crate :: fmt:: imp:: Fixup ;
25
- use crate :: fmt:: { self , Slice } ;
25
+ use crate :: fmt:: { self , Slice , ASCII , UTF8 } ;
26
26
use crate :: util:: {
27
27
copy_and_advance, copy_lifetime, copy_lifetime_mut, unsafe_slice, unsafe_slice_mut,
28
28
} ;
@@ -468,6 +468,20 @@ where
468
468
}
469
469
}
470
470
471
+ impl < A : Atomicity > PartialEq < str > for Tendril < ASCII , A > {
472
+ #[ inline]
473
+ fn eq ( & self , other : & str ) -> bool {
474
+ self . as_byte_slice ( ) == other. as_bytes ( )
475
+ }
476
+ }
477
+
478
+ impl < A : Atomicity > PartialEq < str > for Tendril < UTF8 , A > {
479
+ #[ inline]
480
+ fn eq ( & self , other : & str ) -> bool {
481
+ self . as_byte_slice ( ) == other. as_bytes ( )
482
+ }
483
+ }
484
+
471
485
impl < F , A > Eq for Tendril < F , A >
472
486
where
473
487
F : fmt:: Format ,
@@ -2333,19 +2347,22 @@ mod test {
2333
2347
let bytes_expected = bytes. to_tendril ( ) ;
2334
2348
2335
2349
// char
2336
- assert_eq ! ( string_expected, string. chars( ) . collect( ) ) ;
2350
+ assert_eq ! ( string_expected, string. chars( ) . collect:: < Tendril <_>> ( ) ) ;
2337
2351
let mut tendril = StrTendril :: new ( ) ;
2338
2352
tendril. extend ( string. chars ( ) ) ;
2339
2353
assert_eq ! ( string_expected, tendril) ;
2340
2354
2341
2355
// &u8
2342
- assert_eq ! ( bytes_expected, bytes. iter( ) . collect( ) ) ;
2356
+ assert_eq ! ( bytes_expected, bytes. iter( ) . collect:: < Tendril <_>> ( ) ) ;
2343
2357
let mut tendril = ByteTendril :: new ( ) ;
2344
2358
tendril. extend ( bytes) ;
2345
2359
assert_eq ! ( bytes_expected, tendril) ;
2346
2360
2347
2361
// u8
2348
- assert_eq ! ( bytes_expected, bytes. iter( ) . copied( ) . collect( ) ) ;
2362
+ assert_eq ! (
2363
+ bytes_expected,
2364
+ bytes. iter( ) . copied( ) . collect:: <Tendril <_>>( )
2365
+ ) ;
2349
2366
let mut tendril = ByteTendril :: new ( ) ;
2350
2367
tendril. extend ( bytes. iter ( ) . copied ( ) ) ;
2351
2368
assert_eq ! ( bytes_expected, tendril) ;
0 commit comments