From 3035ab280f7c8bbb3a95afa62fc2bffe43fd8876 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 20 May 2017 12:22:35 -0700 Subject: [PATCH] update test_slice --- tests/test_slice.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/test_slice.rs b/tests/test_slice.rs index 3f4f833e..f545fc20 100644 --- a/tests/test_slice.rs +++ b/tests/test_slice.rs @@ -1,6 +1,7 @@ +#![feature(proc_macro, specialization)] #![allow(dead_code, unused_variables)] -#[macro_use] extern crate pyo3; +extern crate pyo3; use pyo3::*; @@ -19,8 +20,12 @@ fn test_basics() { } -py_class!(pub class Test |py| { - def __getitem__(&self, idx: PyObject) -> PyResult { +#[py::class] +struct Test {} + +#[py::proto] +impl PyMappingProtocol for Test { + fn __getitem__(&self, py: Python, idx: PyObject) -> PyResult { if let Ok(slice) = PySlice::downcast_from(py, idx.clone_ref(py)) { let indices = slice.indices(py, 1000)?; if indices.start == 100 && indices.stop == 200 && indices.step == 1 { @@ -34,7 +39,7 @@ py_class!(pub class Test |py| { } Err(PyErr::new::(py, "error")) } -}); +} #[test] fn test_cls_impl() {