From fd3a0f6d868534bd1dc9ab8d5e16c0b91f402c35 Mon Sep 17 00:00:00 2001 From: yyun-d Date: Sat, 20 Nov 2021 18:59:18 +0900 Subject: [PATCH] implement reduce method to PySlice Signed-off-by: yyun-d --- vm/src/builtins/slice.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vm/src/builtins/slice.rs b/vm/src/builtins/slice.rs index 99bcec732..68e5d6886 100644 --- a/vm/src/builtins/slice.rs +++ b/vm/src/builtins/slice.rs @@ -194,6 +194,20 @@ impl PySlice { let (start, stop, step) = self.inner_indices(length, vm)?; Ok(vm.new_tuple((start, stop, step))) } + + #[allow(clippy::type_complexity)] + #[pymethod(magic)] + fn reduce( + zelf: PyRef, + ) -> PyResult<( + PyTypeRef, + (Option, PyObjectRef, Option), + )> { + Ok(( + zelf.clone_class(), + (zelf.start.clone(), zelf.stop.clone(), zelf.step.clone()), + )) + } } impl Comparable for PySlice {