@@ -9,7 +9,7 @@ use num_bigint::BigInt;
9
9
#[ derive( Debug ) ]
10
10
pub struct PySlice {
11
11
pub start : Option < PyObjectRef > ,
12
- pub stop : Option < PyObjectRef > ,
12
+ pub stop : PyObjectRef ,
13
13
pub step : Option < PyObjectRef > ,
14
14
}
15
15
@@ -30,7 +30,7 @@ fn slice_new(cls: PyClassRef, args: PyFuncArgs, vm: &VirtualMachine) -> PyResult
30
30
let stop = args. bind ( vm) ?;
31
31
PySlice {
32
32
start : None ,
33
- stop : Some ( stop ) ,
33
+ stop,
34
34
step : None ,
35
35
}
36
36
}
@@ -39,7 +39,7 @@ fn slice_new(cls: PyClassRef, args: PyFuncArgs, vm: &VirtualMachine) -> PyResult
39
39
args. bind ( vm) ?;
40
40
PySlice {
41
41
start : Some ( start) ,
42
- stop : Some ( stop ) ,
42
+ stop,
43
43
step : step. into_option ( ) ,
44
44
}
45
45
}
@@ -60,8 +60,8 @@ impl PySliceRef {
60
60
get_property_value ( vm, & self . start )
61
61
}
62
62
63
- fn stop ( self , vm : & VirtualMachine ) -> PyObjectRef {
64
- get_property_value ( vm , & self . stop )
63
+ fn stop ( self , _vm : & VirtualMachine ) -> PyObjectRef {
64
+ self . stop . clone ( )
65
65
}
66
66
67
67
fn step ( self , vm : & VirtualMachine ) -> PyObjectRef {
@@ -77,11 +77,7 @@ impl PySliceRef {
77
77
}
78
78
79
79
pub fn stop_index ( & self , vm : & VirtualMachine ) -> PyResult < Option < BigInt > > {
80
- if let Some ( obj) = & self . stop {
81
- to_index_value ( vm, obj)
82
- } else {
83
- Ok ( None )
84
- }
80
+ to_index_value ( vm, & self . stop )
85
81
}
86
82
87
83
pub fn step_index ( & self , vm : & VirtualMachine ) -> PyResult < Option < BigInt > > {
0 commit comments