Skip to content

Commit 29fbcce

Browse files
committed
glib: Compare lengths in <StrV as PartialEq<[&str]>>::eq too
Also check lenghts in various `StrV` tests.
1 parent 4c43693 commit 29fbcce

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

glib/src/collections/strv.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ impl std::hash::Hash for StrV {
6565

6666
impl PartialEq<[&'_ str]> for StrV {
6767
fn eq(&self, other: &[&'_ str]) -> bool {
68+
if self.len() != other.len() {
69+
return false;
70+
}
71+
6872
for (a, b) in Iterator::zip(self.iter(), other.iter()) {
6973
if a != b {
7074
return false;
@@ -1604,6 +1608,7 @@ mod test {
16041608
StrV::from_glib_full_num(ptr, 4, false)
16051609
};
16061610

1611+
assert_eq!(items.len(), slice.len());
16071612
for (a, b) in Iterator::zip(items.iter(), slice.iter()) {
16081613
assert_eq!(a, b);
16091614
}
@@ -1628,6 +1633,7 @@ mod test {
16281633
StrV::from_glib_container_num(ptr, 4, false)
16291634
};
16301635

1636+
assert_eq!(items.len(), slice.len());
16311637
for (a, b) in Iterator::zip(items.iter(), slice.iter()) {
16321638
assert_eq!(a, b);
16331639
}
@@ -1654,6 +1660,7 @@ mod test {
16541660
res
16551661
};
16561662

1663+
assert_eq!(items.len(), slice.len());
16571664
for (a, b) in Iterator::zip(items.iter(), slice.iter()) {
16581665
assert_eq!(a, b);
16591666
}

0 commit comments

Comments
 (0)