arrayvec
arrayvec copied to clipboard
Add PartialEq implementations
This allows nested comparisons:
fn test_nested_eq() {
let array: ArrayVec<ArrayVec<_, 2>, 5> = (0..3)
.map(|i| ArrayVec::from([i, i + 1]))
.collect();
assert_eq!(array, [[0, 1], [1, 2], [2, 3]]);
}
fn test_vec_of_strings_equality() {
let vec = ArrayVec::from([
ArrayString::<8>::from("one").unwrap(),
ArrayString::<8>::from("two").unwrap(),
ArrayString::<8>::from("three").unwrap(),
]);
assert_eq!(vec, ["one", "two", "three"]);
}
Implementation is similar to std https://doc.rust-lang.org/src/alloc/vec/partial_eq.rs.html#7