From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, junjie.mao@hotmail.com
Subject: Re: [RFC PATCH 1/9] rust: vmstate: add new type safe implementation
Date: Tue, 7 Jan 2025 22:01:19 +0800 [thread overview]
Message-ID: <Z30zr4Se4lhlHcyo@intel.com> (raw)
In-Reply-To: <CABgObfbdFo9B1nedC+Bu2QQfjTL1TOpmSQt0p0a0d0iWev6UKg@mail.gmail.com>
> > Very flexible and powerful. (I even think this code could be released as
> > a new public crate.)
>
> It's probably not _that_ useful in general, unless you're implementing
> this kind of reflection... otherwise I would have found an existing
> solution. :) But yes, it's very powerful.
Personally, I feel that projects that glue C and Rust together require
similar tricks more, making them more challenging.
> Out of curiosity, I asked claude.ai to explain it and it said "This is
> a rather advanced use of Rust's type system and macro capabilities to
> do compile-time reflection - basically inspecting the types of struct
> fields without runtime overhead. While creative, this pattern isn't
> commonly needed in everyday Rust code."
>
> When fed the initial comment from the Rust forum it said "your comment
> about wanting to access <T as SomeTrait>::SOMETHING for a field's type
> is a classic serialization pattern - often used to get things like
> type IDs, serialization formats, or field metadata at compile time".
> That's actually pretty impressive; the LLM was also impressed and it
> started asking me more about it ("Are you building a custom
> serialization framework from scratch, or extending an existing one?").
Incredible, commercial LLMs are so proficient in Rust and provide such
professional comments (even a bit off-topic, it feels like LLMs could
even review patches).
Thank you for providing this interesting example. LLMs are indeed the
good tool to help get started with and practice Rust.
Thanks,
Zhao
next prev parent reply other threads:[~2025-01-07 13:43 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-31 0:23 [RFC PATCH 0/9] rust: (mostly) type safe VMState Paolo Bonzini
2024-12-31 0:23 ` [RFC PATCH 1/9] rust: vmstate: add new type safe implementation Paolo Bonzini
2025-01-07 8:58 ` Zhao Liu
2025-01-07 12:23 ` Paolo Bonzini
2025-01-07 14:01 ` Zhao Liu [this message]
2024-12-31 0:23 ` [RFC PATCH 2/9] rust: vmstate: implement VMState for non-leaf types Paolo Bonzini
2025-01-07 15:43 ` Zhao Liu
2024-12-31 0:23 ` [RFC PATCH 3/9] rust: vmstate: add varray support to vmstate_of! Paolo Bonzini
2025-01-08 3:28 ` Zhao Liu
2025-01-15 10:14 ` Paolo Bonzini
2024-12-31 0:23 ` [RFC PATCH 4/9] rust: vmstate: implement Zeroable for VMStateField Paolo Bonzini
2025-01-06 14:31 ` Zhao Liu
2024-12-31 0:23 ` [RFC PATCH 5/9] rust: vmstate: implement VMState for scalar types Paolo Bonzini
2025-01-08 6:45 ` Zhao Liu
2025-01-15 13:08 ` Paolo Bonzini
2025-01-16 6:59 ` Zhao Liu
2024-12-31 0:23 ` [RFC PATCH 6/9] rust: vmstate: add public utility macros to implement VMState Paolo Bonzini
2025-01-08 8:15 ` Zhao Liu
2024-12-31 0:23 ` [RFC PATCH 7/9] rust: qemu_api: add vmstate_struct and vmstate_cell Paolo Bonzini
2025-01-07 16:49 ` Paolo Bonzini
2024-12-31 0:23 ` [RFC PATCH 8/9] rust: pl011: switch vmstate to new-style macros Paolo Bonzini
2025-01-08 8:27 ` Zhao Liu
2024-12-31 0:23 ` [RFC PATCH 9/9] rust: vmstate: remove translation of C vmstate macros Paolo Bonzini
2025-01-08 8:40 ` 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=Z30zr4Se4lhlHcyo@intel.com \
--to=zhao1.liu@intel.com \
--cc=junjie.mao@hotmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).