diff options
| -rw-r--r-- | libs/binder/rust/src/binder.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libs/binder/rust/src/binder.rs b/libs/binder/rust/src/binder.rs index f79b1b7023..dd0c7b82e0 100644 --- a/libs/binder/rust/src/binder.rs +++ b/libs/binder/rust/src/binder.rs @@ -897,7 +897,7 @@ macro_rules! declare_binder_interface { #[macro_export] macro_rules! declare_binder_enum { { - $enum:ident : $backing:ty { + $enum:ident : [$backing:ty; $size:expr] { $( $name:ident = $value:expr, )* } } => { @@ -905,6 +905,11 @@ macro_rules! declare_binder_enum { pub struct $enum(pub $backing); impl $enum { $( pub const $name: Self = Self($value); )* + + #[inline(always)] + pub const fn enum_values() -> [Self; $size] { + [$(Self::$name),*] + } } impl $crate::parcel::Serialize for $enum { |