diff options
| author | 2022-10-11 01:37:59 +0000 | |
|---|---|---|
| committer | 2022-10-11 01:37:59 +0000 | |
| commit | 10f0616bdab73f3bf07a386986cc23e7d340c0d4 (patch) | |
| tree | 7cc591cb155f87551a39b3e7e11235f550c14fcb | |
| parent | 6333827a7fc876487e8147b52462f1ba5c04c889 (diff) | |
| parent | 32963aca6590443ab4c49a9dbc7fced6819964af (diff) | |
Merge "rust: Fix Debug implementation for declare_binder_enum!" am: 0629658d40 am: 32963aca65
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2239178
Change-Id: Ibe071b4666e0884454df7367e8686f8aff79f35c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | libs/binder/rust/src/binder.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libs/binder/rust/src/binder.rs b/libs/binder/rust/src/binder.rs index 63c8684fa0..976f54d36f 100644 --- a/libs/binder/rust/src/binder.rs +++ b/libs/binder/rust/src/binder.rs @@ -1091,7 +1091,7 @@ macro_rules! declare_binder_enum { } } => { $( #[$attr] )* - #[derive(Debug, Default, Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)] + #[derive(Default, Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub struct $enum(pub $backing); impl $enum { @@ -1104,6 +1104,15 @@ macro_rules! declare_binder_enum { } } + impl std::fmt::Debug for $enum { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self.0 { + $($value => f.write_str(stringify!($name)),)* + _ => f.write_fmt(format_args!("{}", self.0)) + } + } + } + impl $crate::binder_impl::Serialize for $enum { fn serialize(&self, parcel: &mut $crate::binder_impl::BorrowedParcel<'_>) -> std::result::Result<(), $crate::StatusCode> { parcel.write(&self.0) |