diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2024-12-06 17:08:49 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-02-13 12:19:33 +0100 |
commit | 66bcc554d27f693f89bf04df24d474463a90a894 (patch) | |
tree | 1bce253895e365cdef36ee57e1af50607159cbdd /rust/hw | |
parent | ec3eba98967014f942bafb4307303d853d96e7e7 (diff) | |
download | qemu-66bcc554d27f693f89bf04df24d474463a90a894.zip qemu-66bcc554d27f693f89bf04df24d474463a90a894.tar.gz qemu-66bcc554d27f693f89bf04df24d474463a90a894.tar.bz2 |
rust: callbacks: allow passing optional callbacks as ()
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.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/hw')
0 files changed, 0 insertions, 0 deletions