Skip to content

Commit

Permalink
Implement PartialEq<str> for TagRef (#805)
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Wagner <[email protected]>
  • Loading branch information
nwagner84 authored Aug 21, 2024
1 parent b952607 commit b66448a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/pica-record/src/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ impl<'a, T: AsRef<[u8]>> PartialEq<T> for TagRef<'a> {
}
}

impl<'a> PartialEq<str> for TagRef<'a> {
/// Compare a `TagRef` with a string slice.
///
/// ```rust
/// use pica_record::{Level, TagRef};
///
/// # fn main() { example().unwrap(); }
/// fn example() -> anyhow::Result<()> {
/// assert_eq!(&TagRef::new("003@"), "003@");
/// assert_eq!(TagRef::new("003@"), "003@");
/// Ok(())
/// }
/// ```
#[inline]
fn eq(&self, other: &str) -> bool {
self.0 == other
}
}

impl<'a> Deref for TagRef<'a> {
type Target = BStr;

Expand Down

0 comments on commit b66448a

Please sign in to comment.