list,tuple,sequence: add slice indexing#1829
Conversation
cd83a91 to
b16cf66
Compare
|
Thanks for the great review! I reworked this to be a macro as suggested. (I threw it in I also made conditional use of e.g. |
b16cf66 to
21759b9
Compare
src/types/sequence.rs
Outdated
| .expect("sequence slice operation failed") | ||
| } | ||
|
|
||
| index_impls!(PySequence, PyAny, "sequence", sequence_len, sequence_slice); |
There was a problem hiding this comment.
I see that the output of get_slice is currently not another PySequence, should we change this? IMO it's similar to expecting a sequence out of repeat etc.
There was a problem hiding this comment.
Yeah, I think that's reasonable.
I guess as before, implementations may actually not return a sequence. Then using further sequence APIs will fail, which is ok and sound.
Very nice (also that we can do it conditionally)! |
21759b9 to
3a90ff7
Compare
Follow up to #1825 to add range indexing.
Given that the decision in #1733 was that we are trying to make these APIs feel as much like idiomatic Rust as possible, I opted to make them panic on out of bounds.
This probably closes #1667 ?