list/tuple/sequence: implement Index#1825
Conversation
b4af0f5 to
611126d
Compare
davidhewitt
left a comment
There was a problem hiding this comment.
👍 looks like a great start!
What do you think of supporting full slice indexing? I think this means either implementing SliceIndex or just implementing Index directly for Range<usize>, RangeFull, RangeInclusive<usize> etc.
|
Yeah, I though about it, but that runs into API consistency again: do we want to panic on invalid indices or not? |
There was a problem hiding this comment.
That's fair enough. I think for out of bounds slice indexing we should probably panic (to match Rust), given that we already deviated from Python by not supporting negative indexing. That also has the nice dual that again get_slice is the non-panicking companion, even if it doesn't return an error.
I'm happy to implement SliceIndex myself in a follow-up.
See #1667