Re:Crabtime: Zig's Comptime in Rust
by WhyNotHugo on Saturday March 22, 2025 @10:30AM
(#43445841)
What Rust is missing is reflection and the ability to define types and functions via code. Zig's comptime is often used for this: to generate code (for example, a serialiser for a type) or to generate types (generics being a typical thing, but lots of other usages are viable).
[ Parent
| on HN ]
Re:Crabtime: Zig's Comptime in Rust
by vlovich123 on Saturday March 22, 2025 @04:00PM
(#43448214)
You can define types and functions via code via macros. For example, [1] which creates a new sibling type and injects a ::builder method into your type.
And you can add reflection [2]. So if you can add what you need via crates, is the language actually missing it or is it just not as ergonomic / performant as it needs to be or is it an education problem?