]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: str: implement `PartialEq` for `BStr`
authorAndreas Hindborg <a.hindborg@kernel.org>
Thu, 27 Feb 2025 14:38:07 +0000 (15:38 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Thu, 20 Mar 2025 20:44:47 +0000 (21:44 +0100)
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>
rust/kernel/str.rs

index 28e2201604d67800f8d6b8f69065dc32710b891e..002dcddf7c7687522a0acbff3ce6f65fa890e216 100644 (file)
@@ -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