Merge pull request #3798 from davidhewitt/beta-map-clone

ci: fix beta clippy `map_clone` warning
This commit is contained in:
Bruno Kolenbrander 2024-02-05 08:48:14 +00:00 committed by GitHub
commit 7938d4cadc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -1443,6 +1443,9 @@ where
{
/// Extracts `Self` from the source `PyObject`.
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
// 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)
}
}

View File

@ -264,13 +264,13 @@ impl Sequence {
self.values.len()
}
fn __getitem__(&self, index: SequenceIndex<'_>) -> PyResult<PyObject> {
fn __getitem__(&self, index: SequenceIndex<'_>, py: Python<'_>) -> PyResult<PyObject> {
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