In documents, the sign is determined Index:
pub trait Index<Idx> where Idx: ?Sized {
type Output: ?Sized;
fn index(&self, index: Idx) -> &Self::Output;
}
Since the type of the parameter Index Idx, and not &Idx, the method Indexshould take responsibility for the value passed.
Is there a reason for this limitation? I know that 9 times out of 10 will use something like an integer type that outputs Copy, but I'm just wondering why the borrowed value will be less capable of acting like an index.
source
share