Alexandre Courbot
2025-Aug-08 09:13 UTC
[PATCH 0/4] rust: add `TryFrom` and `Into` derive macros
On Sun Aug 3, 2025 at 11:20 PM JST, Jesung Yang wrote:> This patch series introduces derive macros for `TryFrom` and `Into` > traits. > > A few enhancements were made to the custom `quote!()` macro to write > the derive macro. These include support for additional punctuation > tokens and a fix for an unused variable warning when quoting simple > forms. Detailed information about these enhancements is provided in the > relevant patches. > > This series builds on the previous work [1], where the `FromPrimitive` > trait was considered too heavy for the current use cases. In response > to the emerging need for functionality similar to `ToPrimitive`, this > series also implements the `Into` derive macro. > > The original discussion can be found on Zulip [2]. > > [1] https://lore.kernel.org/rust-for-linux/cover.1750689857.git.y.j3ms.n at gmail.com/ > [2] https://rust-for-linux.zulipchat.com/#narrow/channel/288089/topic/x/near/524335626I have tried this series on nova-core and it allowed me to remove 150 lines of boiletplate just like that. As far as nova-core is concerned, this is a perfect fit. For the larger kernel, where using the right type is essential and where we want to avoid error paths whenever possible, I also feel like this is a much better fit than the initial `FromPrimitive`. But it would be nice to hear other opinions on the matter. I will try to review as much as my proc-macro knowledge allows me to, but for now: Tested-by: Alexandre Courbot <acourbot at nvidia.com>