When hashing / eq-ing on a Vec, is it guaranteed that it depends only on (1) length of vector and (2) elements of vector ?
(In particular, I'm concerned that two vectors with same length, same elements, but different CAPACITY might end up different in the eyes of eq/hash).
Yes, in fact they are implemented by passing on to the corresponding implementations for slices, where capacities are no longer relevant.
And this is guaranteed to remain true because
Borrow<[T]>, and the
Borrow trait requires that:
Hash must be equivalent for borrowed and owned values:
x.borrow() == y.borrow() should give the same result as
x == y .
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.