File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -1466,6 +1466,10 @@ impl std::hash::Hash for StrVRef {
14661466
14671467impl PartialEq < [ & ' _ str ] > for StrVRef {
14681468 fn eq ( & self , other : & [ & ' _ str ] ) -> bool {
1469+ if self . len ( ) != other. len ( ) {
1470+ return false ;
1471+ }
1472+
14691473 for ( a, b) in Iterator :: zip ( self . iter ( ) , other. iter ( ) ) {
14701474 if a != b {
14711475 return false ;
@@ -1847,4 +1851,16 @@ mod test {
18471851 assert ! ( ( * strv. as_ptr( ) . add( strv. len( ) ) ) . is_null( ) ) ;
18481852 }
18491853 }
1854+
1855+ #[ test]
1856+ fn test_strv_ref_eq_str_slice ( ) {
1857+ let strv = StrV :: from ( & [ crate :: gstr!( "a" ) ] [ ..] ) ;
1858+ let strv_ref: & StrVRef = strv. as_ref ( ) ;
1859+
1860+ // Test `impl PartialEq<[&'_ str]> for StrVRef`
1861+ assert_eq ! ( strv_ref, & [ "a" ] [ ..] ) ;
1862+ assert_ne ! ( strv_ref, & [ ] [ ..] ) ;
1863+ assert_ne ! ( strv_ref, & [ "a" , "b" ] [ ..] ) ;
1864+ assert_ne ! ( strv_ref, & [ "b" ] [ ..] ) ;
1865+ }
18501866}
You can’t perform that action at this time.
0 commit comments