In the code below, I get the same result whether I use lenor count:
fn main() {
let vector = [0, 1, 2];
assert_eq!(vector.iter().count(), vector.iter().len());
}
len seems to be more general as I can also do this:
assert_eq!(vector.len(), 3);
So what is the difference between the two ... why use one and not the other?
source
share