[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 11/12] rust: qemu-api-macros: add automatic TryFrom/TryInto d
From: |
Zhao Liu |
Subject: |
Re: [PATCH 11/12] rust: qemu-api-macros: add automatic TryFrom/TryInto derivation |
Date: |
Thu, 26 Dec 2024 15:14:19 +0800 |
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 <pbonzini@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 <pbonzini@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.liu@intel.com>
- [PATCH 00/12] Next round of qemu_api patches, Paolo Bonzini, 2024/12/20
- [PATCH 04/12] rust: macros: check that #[derive(Object)] requires #[repr(C)], Paolo Bonzini, 2024/12/20
- [PATCH 01/12] rust: qom: add ParentField, Paolo Bonzini, 2024/12/20
- [PATCH 02/12] rust: add a utility module for compile-time type checks, Paolo Bonzini, 2024/12/20
- [PATCH 03/12] rust: macros: check that the first field of a #[derive(Object)] struct is a ParentField, Paolo Bonzini, 2024/12/20
- [PATCH 11/12] rust: qemu-api-macros: add automatic TryFrom/TryInto derivation, Paolo Bonzini, 2024/12/20
- Re: [PATCH 11/12] rust: qemu-api-macros: add automatic TryFrom/TryInto derivation,
Zhao Liu <=
- [PATCH 07/12] rust: pl011: only leave embedded object initialization in instance_init, Paolo Bonzini, 2024/12/20
- [PATCH 09/12] rust: qdev: expose inherited methods to subclasses of SysBusDevice, Paolo Bonzini, 2024/12/20
- [PATCH 05/12] rust: qom: automatically use Drop trait to implement instance_finalize, Paolo Bonzini, 2024/12/20
- [PATCH 10/12] rust: qemu-api-macros: extend error reporting facility to parse errors, Paolo Bonzini, 2024/12/20
- [PATCH 06/12] rust: qom: move device_id to PL011 class side, Paolo Bonzini, 2024/12/20
- [PATCH 08/12] rust: qom: make INSTANCE_POST_INIT take a shared reference, Paolo Bonzini, 2024/12/20