diff options
| -rw-r--r-- | libs/binder/rust/src/parcel/file_descriptor.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/binder/rust/src/parcel/file_descriptor.rs b/libs/binder/rust/src/parcel/file_descriptor.rs index b0dea945e0..4d3d59afb0 100644 --- a/libs/binder/rust/src/parcel/file_descriptor.rs +++ b/libs/binder/rust/src/parcel/file_descriptor.rs @@ -60,6 +60,16 @@ impl IntoRawFd for ParcelFileDescriptor { } } +impl PartialEq for ParcelFileDescriptor { + // Since ParcelFileDescriptors own the FD, if this function ever returns true (and it is used to + // compare two different objects), then it would imply that an FD is double-owned. + fn eq(&self, other: &Self) -> bool { + self.as_raw_fd() == other.as_raw_fd() + } +} + +impl Eq for ParcelFileDescriptor {} + impl Serialize for ParcelFileDescriptor { fn serialize(&self, parcel: &mut BorrowedParcel<'_>) -> Result<()> { let fd = self.0.as_raw_fd(); |