Skip to content

Commit 3eff946

Browse files
Andreas Hindborgojeda
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> Reviewed-by: Fiona Behrens <me@kloenk.dev> Tested-by: Daniel Gomez <da.gomez@samsung.com> Link: https://lore.kernel.org/r/20250227-module-params-v3-v8-1-ceeee85d9347@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 3ba83d3 commit 3eff946

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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)