2 ms·
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,
by WhyNotHugo 2y ago
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).
- vlovich123 2y agoYou 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? [1] https://docs.rs/typed-builder/latest/typed_builder/ https://docs.rs/typed-builder/latest/typed_builder/ [2] https://docs.rs/reflect/latest/reflect/ https://docs.rs/reflect/latest/reflect/