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 {
1466
1466
1467
1467
impl PartialEq < [ & ' _ str ] > for StrVRef {
1468
1468
fn eq ( & self , other : & [ & ' _ str ] ) -> bool {
1469
+ if self . len ( ) != other. len ( ) {
1470
+ return false ;
1471
+ }
1472
+
1469
1473
for ( a, b) in Iterator :: zip ( self . iter ( ) , other. iter ( ) ) {
1470
1474
if a != b {
1471
1475
return false ;
@@ -1847,4 +1851,16 @@ mod test {
1847
1851
assert ! ( ( * strv. as_ptr( ) . add( strv. len( ) ) ) . is_null( ) ) ;
1848
1852
}
1849
1853
}
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
+ }
1850
1866
}
You can’t perform that action at this time.
0 commit comments