@@ -22,7 +22,7 @@ use encoding::{self, DecoderTrap, EncoderTrap, EncodingRef};
2222
2323use crate :: buf32:: { self , Buf32 } ;
2424use crate :: fmt:: imp:: Fixup ;
25- use crate :: fmt:: { self , Slice } ;
25+ use crate :: fmt:: { self , Slice , ASCII , UTF8 } ;
2626use crate :: util:: {
2727 copy_and_advance, copy_lifetime, copy_lifetime_mut, unsafe_slice, unsafe_slice_mut,
2828} ;
@@ -468,6 +468,20 @@ where
468468 }
469469}
470470
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+
471485impl < F , A > Eq for Tendril < F , A >
472486where
473487 F : fmt:: Format ,
@@ -2333,19 +2347,22 @@ mod test {
23332347 let bytes_expected = bytes. to_tendril ( ) ;
23342348
23352349 // char
2336- assert_eq ! ( string_expected, string. chars( ) . collect( ) ) ;
2350+ assert_eq ! ( string_expected, string. chars( ) . collect:: < Tendril <_>> ( ) ) ;
23372351 let mut tendril = StrTendril :: new ( ) ;
23382352 tendril. extend ( string. chars ( ) ) ;
23392353 assert_eq ! ( string_expected, tendril) ;
23402354
23412355 // &u8
2342- assert_eq ! ( bytes_expected, bytes. iter( ) . collect( ) ) ;
2356+ assert_eq ! ( bytes_expected, bytes. iter( ) . collect:: < Tendril <_>> ( ) ) ;
23432357 let mut tendril = ByteTendril :: new ( ) ;
23442358 tendril. extend ( bytes) ;
23452359 assert_eq ! ( bytes_expected, tendril) ;
23462360
23472361 // u8
2348- assert_eq ! ( bytes_expected, bytes. iter( ) . copied( ) . collect( ) ) ;
2362+ assert_eq ! (
2363+ bytes_expected,
2364+ bytes. iter( ) . copied( ) . collect:: <Tendril <_>>( )
2365+ ) ;
23492366 let mut tendril = ByteTendril :: new ( ) ;
23502367 tendril. extend ( bytes. iter ( ) . copied ( ) ) ;
23512368 assert_eq ! ( bytes_expected, tendril) ;
0 commit comments