All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org
Subject: Re: [PATCH 2/5] rust: use inline const expressions
Date: Tue, 6 May 2025 17:11:47 +0800	[thread overview]
Message-ID: <aBnSUzH1RuYp123b@intel.com> (raw)
In-Reply-To: <20250505100854.73936-3-pbonzini@redhat.com>

On Mon, May 05, 2025 at 12:08:51PM +0200, Paolo Bonzini wrote:
> Date: Mon,  5 May 2025 12:08:51 +0200
> From: Paolo Bonzini <pbonzini@redhat.com>
> Subject: [PATCH 2/5] rust: use inline const expressions
> X-Mailer: git-send-email 2.49.0
> 
> They were stabilized in Rust 1.79.0.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  docs/devel/rust.rst            |  9 +++------
>  rust/qemu-api/src/callbacks.rs | 27 +--------------------------
>  rust/qemu-api/src/chardev.rs   |  2 +-
>  rust/qemu-api/src/qdev.rs      |  2 +-
>  rust/qemu-api/src/timer.rs     |  2 +-
>  rust/qemu-api/src/vmstate.rs   |  2 +-
>  6 files changed, 8 insertions(+), 36 deletions(-)

...

> diff --git a/rust/qemu-api/src/chardev.rs b/rust/qemu-api/src/chardev.rs
> index 6e0590d758e..cb27be52569 100644
> --- a/rust/qemu-api/src/chardev.rs
> +++ b/rust/qemu-api/src/chardev.rs
> @@ -138,7 +138,7 @@ pub fn enable_handlers<
>              F::call((owner, event))
>          }
>  
> -        let _: () = CanReceiveFn::ASSERT_IS_SOME;
> +        const { assert!(CanReceiveFn::IS_SOME) };

Do you think it's a good idea to warp this as a helper for easy
callback calls?

>          let receive_cb: Option<unsafe extern "C" fn(*mut c_void, *const u8, c_int)> =
>              if ReceiveFn::is_some() {
>                  Some(rust_receive_cb::<T, ReceiveFn>)

Thanks,
Zhao



  reply	other threads:[~2025-05-06  8:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-05 10:08 [PATCH preview 0/5] rust: allow minimum version of 1.83 Paolo Bonzini
2025-05-05 10:08 ` [PATCH 1/5] meson, cargo: require Rust 1.83.0 Paolo Bonzini
2025-05-05 10:08 ` [PATCH 2/5] rust: use inline const expressions Paolo Bonzini
2025-05-06  9:11   ` Zhao Liu [this message]
2025-05-06 10:56     ` Paolo Bonzini
2025-05-05 10:08 ` [PATCH 3/5] rust: vmstate: convert to use builder pattern Paolo Bonzini
2025-05-06  9:55   ` Zhao Liu
2025-05-06 10:33     ` Paolo Bonzini
2025-05-05 10:08 ` [PATCH 4/5] rust: vmstate: use const_refs_to_static Paolo Bonzini
2025-05-07  7:59   ` Zhao Liu
2025-05-05 10:08 ` [PATCH 5/5] rust: qdev: const_refs_to_static Paolo Bonzini
2025-05-06  8:56 ` [PATCH preview 0/5] rust: allow minimum version of 1.83 Zhao Liu
2025-05-06  8:43   ` Paolo Bonzini
2025-05-06  9:26     ` Zhao Liu
2025-05-06  9:44       ` Daniel P. Berrangé
2025-05-06  9:48       ` Daniel P. Berrangé
2025-05-06 10:54         ` Paolo Bonzini
2025-05-06 11:52           ` Daniel P. Berrangé
2025-05-06 13:41             ` Paolo Bonzini
2025-05-06 15:56           ` Zhao Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aBnSUzH1RuYp123b@intel.com \
    --to=zhao1.liu@intel.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-rust@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.