On Fri, Dec 20, 2024 at 03:29:53PM +0100, Paolo Bonzini wrote: > Date: Fri, 20 Dec 2024 15:29:53 +0100 > From: Paolo Bonzini <pbonz...@redhat.com> > Subject: [PATCH 11/12] rust: qemu-api-macros: add automatic TryFrom/TryInto > derivation > X-Mailer: git-send-email 2.47.1 > > This is going to be fairly common. Using a custom procedural macro > provides better error messages and automatically finds the right > type. > > Note that this is different from the same-named macro in the > derive_more crate. That one provides conversion from e.g. tuples > to enums with tuple variants, not from integers to enums. > > Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> > --- > rust/hw/char/pl011/src/lib.rs | 28 +------------ > rust/qemu-api-macros/src/lib.rs | 74 ++++++++++++++++++++++++++++++++- > 2 files changed, 73 insertions(+), 29 deletions(-) >
This improvement is also very elegant. Reviewed-by: Zhao Liu <zhao1....@intel.com>