Make a generic function for Index<&I> and Index<I>


#1

The real issue is here: https://github.com/Kerollmops/ripin-rs/issues/9

I am trying to make a method that can get a generic type Index<I> or Index<&I> in parameter, is it possible or not ?
With the help of the AsRef and the Into traits maybe ?


#2

Borrow<T> is implemented for both T and &T, so using that is a possibility. (This is unlike AsRef<T>, which is not implemented for T).


#3

Ho ! You’re a gentleman ! Thank you, I will look at this right now.


#4

Hum it seems to be a Trait not adapted for this situation.
I will make a specific Trait to handle my problem (Index<I> and Index<&I>).


#5

for <T: Borrow<I>, I, W: Index<T>> ... or something like that?