From 8fe983be2a8a78ec042b3fed4444ace1d3e44b78 Mon Sep 17 00:00:00 2001 From: kngwyu Date: Fri, 9 Oct 2020 00:21:42 +0900 Subject: [PATCH] Fix a clippy warning --- pyo3-derive-backend/src/from_pyobject.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/pyo3-derive-backend/src/from_pyobject.rs b/pyo3-derive-backend/src/from_pyobject.rs index d35af6da9dd..8d8dc95660a 100644 --- a/pyo3-derive-backend/src/from_pyobject.rs +++ b/pyo3-derive-backend/src/from_pyobject.rs @@ -133,7 +133,9 @@ impl<'a> Container<'a> { "Cannot derive FromPyObject for empty structs and variants.", )); } - let transparent = attrs.iter().any(ContainerAttribute::transparent); + let transparent = attrs + .iter() + .any(|attr| *attr == ContainerAttribute::Transparent); if transparent { Self::check_transparent_len(fields)?; } @@ -182,7 +184,6 @@ impl<'a> Container<'a> { let err_name = attrs .iter() .find_map(|a| a.annotation()) - .cloned() .unwrap_or_else(|| path.segments.last().unwrap().ident.to_string()); let v = Container { @@ -306,18 +307,10 @@ enum ContainerAttribute { } impl ContainerAttribute { - /// Return whether this attribute is `Transparent` - fn transparent(&self) -> bool { - match self { - ContainerAttribute::Transparent => true, - _ => false, - } - } - /// Convenience method to access `ErrorAnnotation`. - fn annotation(&self) -> Option<&String> { + fn annotation(&self) -> Option { match self { - ContainerAttribute::ErrorAnnotation(s) => Some(s), + ContainerAttribute::ErrorAnnotation(s) => Some(s.to_string()), _ => None, } }