Example:
use std::ops::Index;
fn test(v: &Vec<Vec<i32>>) {
let t = v.index(0); //ok
let t = v[0]; //error, Vec<i32> does not implement Copy trait
}
Playground
Why does that happen? As specified in the documentation:
fn index(&self, index: I) -> &<Vec<T, A> as Index<I>>::Output
Performs the indexing (
container[index]
) operation
So it should be the same.