File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed
Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -276,20 +276,12 @@ impl PyList {
276276 vm : & VirtualMachine ,
277277 ) -> PyResult < usize > {
278278 let len = self . len ( ) ;
279- let start: usize = match start {
280- OptionalArg :: Missing => 0 ,
281- OptionalArg :: Present ( obj) => {
282- let int: PyIntRef = obj. try_into_value ( vm) ?;
283- pyint_saturate_index ( int, len)
284- }
285- } ;
286- let stop: usize = match stop {
287- OptionalArg :: Missing => len,
288- OptionalArg :: Present ( obj) => {
289- let int: PyIntRef = obj. try_into_value ( vm) ?;
290- pyint_saturate_index ( int, len)
291- }
279+ let saturate = |obj : PyObjectRef , len| -> PyResult < _ > {
280+ obj. try_into_value ( vm)
281+ . map ( |int : PyIntRef | pyint_saturate_index ( int, len) )
292282 } ;
283+ let start = start. map_or ( Ok ( 0 ) , |obj| saturate ( obj, len) ) ?;
284+ let stop = stop. map_or ( Ok ( len) , |obj| saturate ( obj, len) ) ?;
293285 let index = self . mut_index_range ( vm, & needle, start..stop) ?;
294286 if let Some ( index) = index. into ( ) {
295287 Ok ( index)
You can’t perform that action at this time.
0 commit comments