Why could index take an Idx: ?Sized

I was just browsing some docs, and I saw that Index is defined like so:

pub trait Index<Idx: ?Sized> {
    type Output: ?Sized;

    fn index(&self, index: Idx) -> &Self::Output;

I understand the structure and function of this trait (It’s to index things), but what I unfortunately don’t get is why Idx: ?Sized if the only member of this trait takes index: Idx, meaning that it’s leading on to the idea that Idx could somehow be unsized, but then making it impossible to implement.

Was this meant to be an api design choice, a forward-compatibility choice for when unsized locals land, or just a mistake (Probably not a mistake though)?

Yes, this is to be forward compatible with usized-locals, or some other similar proposal.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.