1- use super :: { PositionIterInternal , PyGenericAlias , PyIntRef , PyTupleRef , PyType , PyTypeRef } ;
1+ use super :: { PositionIterInternal , PyGenericAlias , PyTupleRef , PyType , PyTypeRef } ;
22use crate :: common:: lock:: {
33 PyMappedRwLockReadGuard , PyMutex , PyRwLock , PyRwLockReadGuard , PyRwLockWriteGuard ,
44} ;
@@ -9,8 +9,8 @@ use crate::{
99 iter:: PyExactSizeIterator ,
1010 protocol:: { PyIterReturn , PyMappingMethods , PySequence , PySequenceMethods } ,
1111 recursion:: ReprGuard ,
12- sequence:: { MutObjectSequenceOp , SequenceExt , SequenceMutExt } ,
13- sliceable:: { SequenceIndex , SequenceIndexOp , SliceableSequenceMutOp , SliceableSequenceOp } ,
12+ sequence:: { MutObjectSequenceOp , OptionalRangeArgs , SequenceExt , SequenceMutExt } ,
13+ sliceable:: { SequenceIndex , SliceableSequenceMutOp , SliceableSequenceOp } ,
1414 types:: {
1515 AsMapping , AsSequence , Comparable , Constructor , Hashable , Initializer , IterNext ,
1616 IterNextIterable , Iterable , PyComparisonOp , Unconstructible , Unhashable ,
@@ -269,17 +269,10 @@ impl PyList {
269269 fn index (
270270 & self ,
271271 needle : PyObjectRef ,
272- start : OptionalArg < PyObjectRef > ,
273- stop : OptionalArg < PyObjectRef > ,
272+ range : OptionalRangeArgs ,
274273 vm : & VirtualMachine ,
275274 ) -> PyResult < usize > {
276- let len = self . len ( ) ;
277- let saturate = |obj : PyObjectRef , len| -> PyResult < _ > {
278- obj. try_into_value ( vm)
279- . map ( |int : PyIntRef | int. as_bigint ( ) . saturated_at ( len) )
280- } ;
281- let start = start. map_or ( Ok ( 0 ) , |obj| saturate ( obj, len) ) ?;
282- let stop = stop. map_or ( Ok ( len) , |obj| saturate ( obj, len) ) ?;
275+ let ( start, stop) = range. saturate ( self . len ( ) , vm) ?;
283276 let index = self . mut_index_range ( vm, & needle, start..stop) ?;
284277 if let Some ( index) = index. into ( ) {
285278 Ok ( index)
0 commit comments