summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorAndreas Hindborg <a.hindborg@kernel.org>2025-02-27 15:38:07 +0100
committerMiguel Ojeda <ojeda@kernel.org>2025-03-20 21:44:47 +0100
commit3eff946dfec732ca9e8585bd44f93acc12646d21 (patch)
tree023a4b56ac3681cf8604412bf48a66d8c58f8c63 /rust
parent3ba83d37615ac66d8f52e745dedf9510e493fe97 (diff)
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>
Diffstat (limited to 'rust')
-rw-r--r--rust/kernel/str.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
index 28e2201604d6..002dcddf7c76 100644
--- a/rust/kernel/str.rs
+++ b/rust/kernel/str.rs
@@ -108,6 +108,12 @@ impl Deref for BStr {
}
}
+impl PartialEq for BStr {
+ fn eq(&self, other: &Self) -> bool {
+ self.deref().eq(other.deref())
+ }
+}
+
/// Creates a new [`BStr`] from a string literal.
///
/// `b_str!` converts the supplied string literal to byte string, so non-ASCII