diff options
| author | 2021-12-16 06:01:46 +0000 | |
|---|---|---|
| committer | 2021-12-16 06:01:46 +0000 | |
| commit | a43a2fab987a3138ff8d02cd6b3a742ddc3f9dcc (patch) | |
| tree | 40845c1a0462d98e4c34db288dea314fff22fdcb /libs | |
| parent | b5c760a2f0a576cf1e659d6b3e490b06b77d41f3 (diff) | |
| parent | 9040251850e61c26b9824c3677ced7208d8a446f (diff) | |
libbinder_rs: PartialEq for ParcelFileDescriptor am: bbfe6b1232 am: 9040251850
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1924237
Change-Id: I35280ef1d0f218d1a062bb8668fba0be50df70c8
Diffstat (limited to 'libs')
| -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(); |