Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: sync: implement == operator for ARef

Rust Binder wants to perform a comparison between ARef<Task> and &Task,
so define the == operator for ARef<_> when compared with another ARef<_>
or just a reference. The operator is implemented in terms of the same
operator applied to the inner type.

Note that PartialEq<U> cannot be implemented because it would overlap
with the impl for ARef<U>.

Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260324-close-fd-check-current-v3-1-b94274bedac7@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alice Ryhl and committed by
Greg Kroah-Hartman
18e9fafb 5326a18e

+22
+22
rust/kernel/sync/aref.rs
··· 170 170 unsafe { T::dec_ref(self.ptr) }; 171 171 } 172 172 } 173 + 174 + impl<T, U> PartialEq<ARef<U>> for ARef<T> 175 + where 176 + T: AlwaysRefCounted + PartialEq<U>, 177 + U: AlwaysRefCounted, 178 + { 179 + #[inline] 180 + fn eq(&self, other: &ARef<U>) -> bool { 181 + T::eq(&**self, &**other) 182 + } 183 + } 184 + impl<T: AlwaysRefCounted + Eq> Eq for ARef<T> {} 185 + 186 + impl<T, U> PartialEq<&'_ U> for ARef<T> 187 + where 188 + T: AlwaysRefCounted + PartialEq<U>, 189 + { 190 + #[inline] 191 + fn eq(&self, other: &&U) -> bool { 192 + T::eq(&**self, other) 193 + } 194 + }