On Fri, Feb 07, 2025 at 11:16:14AM +0100, Paolo Bonzini wrote: > Date: Fri, 7 Feb 2025 11:16:14 +0100 > From: Paolo Bonzini <pbonz...@redhat.com> > Subject: [PATCH 03/12] rust: callbacks: allow passing optional callbacks as > () > X-Mailer: git-send-email 2.48.1 > > In some cases, callbacks are optional. Using "Some(function)" and "None" > does not work well, because when someone writes "None" the compiler does > not know what to use for "F" in "Option<F>". > > Therefore, adopt () to mean a "null" callback. It is possible to enforce > that a callback is valid by adding a "let _: () = F::ASSERT_IS_SOME" before > the invocation of F::call. > > Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> > --- > rust/qemu-api/src/callbacks.rs | 97 ++++++++++++++++++++++++++++++++++ > 1 file changed, 97 insertions(+) >
Reviewed-by: Zhao Liu <zhao1....@intel.com>