Skip to content

Commit

Permalink
Fix a clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kngwyu committed Oct 8, 2020
1 parent ff64431 commit 8fe983b
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions pyo3-derive-backend/src/from_pyobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<String> {
match self {
ContainerAttribute::ErrorAnnotation(s) => Some(s),
ContainerAttribute::ErrorAnnotation(s) => Some(s.to_string()),
_ => None,
}
}
Expand Down

0 comments on commit 8fe983b

Please sign in to comment.