From de93d15eebfd2045f8cf04dec6ef6ba16f8e3eba Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 5 Feb 2024 07:57:27 +0000 Subject: [PATCH] ci: fix beta clippy `map_clone` warning --- src/instance.rs | 3 +++ tests/test_proto_methods.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/instance.rs b/src/instance.rs index 92fc0185..d21cc307 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -1443,6 +1443,9 @@ where { /// Extracts `Self` from the source `PyObject`. fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { + // TODO update MSRV past 1.59 and use .cloned() to make + // clippy happy + #[allow(clippy::map_clone)] ob.downcast().map(Clone::clone).map_err(Into::into) } } diff --git a/tests/test_proto_methods.rs b/tests/test_proto_methods.rs index a328ab9e..50dd99ce 100644 --- a/tests/test_proto_methods.rs +++ b/tests/test_proto_methods.rs @@ -264,13 +264,13 @@ impl Sequence { self.values.len() } - fn __getitem__(&self, index: SequenceIndex<'_>) -> PyResult { + fn __getitem__(&self, index: SequenceIndex<'_>, py: Python<'_>) -> PyResult { match index { SequenceIndex::Integer(index) => { let uindex = self.usize_index(index)?; self.values .get(uindex) - .map(Clone::clone) + .map(|o| o.clone_ref(py)) .ok_or_else(|| PyIndexError::new_err(index)) } // Just to prove that slicing can be implemented