Skip to content

Commit

Permalink
Let try_get_attribute() use either &str or &[u8]
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed Mar 27, 2021
1 parent 7266bbc commit b24cb9a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,13 @@ impl<'a> BytesStart<'a> {
}

/// Try to get an attribute
pub fn try_get_attribute(&'a self, attr_name: &[u8]) -> Result<Option<Attribute<'a>>> {
pub fn try_get_attribute<N: AsRef<[u8]> + Sized>(
&'a self,
attr_name: N,
) -> Result<Option<Attribute<'a>>> {
for a in self.attributes() {
let a = a?;
if a.key == attr_name {
if a.key == attr_name.as_ref() {
return Ok(Some(a));
}
}
Expand Down

0 comments on commit b24cb9a

Please sign in to comment.