Skip to content

Commit 854e576

Browse files
Andreas Hindborgjannau
authored andcommitted
rust: str: implement PartialEq for BStr
Implement `PartialEq` for `BStr` by comparing underlying byte slices. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Tested-by: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
1 parent 7d5d5e8 commit 854e576

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

rust/kernel/str.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ impl Deref for BStr {
108108
}
109109
}
110110

111+
impl PartialEq for BStr {
112+
fn eq(&self, other: &Self) -> bool {
113+
self.deref().eq(other.deref())
114+
}
115+
}
116+
111117
/// Creates a new [`BStr`] from a string literal.
112118
///
113119
/// `b_str!` converts the supplied string literal to byte string, so non-ASCII

0 commit comments

Comments
 (0)