From: Andreas Hindborg Date: Thu, 27 Feb 2025 14:38:07 +0000 (+0100) Subject: rust: str: implement `PartialEq` for `BStr` X-Git-Tag: v6.15-rc1~93^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3eff946dfec732ca9e8585bd44f93acc12646d21;p=thirdparty%2Fkernel%2Fstable.git rust: str: implement `PartialEq` for `BStr` Implement `PartialEq` for `BStr` by comparing underlying byte slices. Reviewed-by: Alice Ryhl Reviewed-by: Gary Guo Reviewed-by: Daniel Almeida Tested-by: Daniel Almeida Signed-off-by: Andreas Hindborg Reviewed-by: Fiona Behrens Tested-by: Daniel Gomez Link: https://lore.kernel.org/r/20250227-module-params-v3-v8-1-ceeee85d9347@kernel.org Signed-off-by: Miguel Ojeda --- diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index 28e2201604d67..002dcddf7c768 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