2 ms·
You probably ran into this stuff not being built-in. You can add it on via a macro pretty easily, except that the "selection of backing field" is built in via t
by steveklabnik 6y ago
You probably ran into this stuff not being built-in. You can add it on via a macro pretty easily, except that the "selection of backing field" is built in via the repr attribute. An example of this would be packages like https://docs.rs/enum_derive/0.1.7/enum_derive/ https://docs.rs/enum_derive/0.1.7/enum_derive/
The other stuff isn't built in because it would add a bunch of code you may or may not want to your build, and it's easy enough to opt into. We also could solve that problem, in theory, a few ways, but there just hasn't been a ton of demand for it, so it hasn't been done.
With bitfields, there has been increasing demand lately, so we'll see.
- alkonaut 6y agoI constantly run into the situation where you make 2 or more constants with a prefix. That always felt like a smell to me - but it might be because in C# it would be. I'm talking about code that ends up looking like this: https://github.com/retep998/winapi-rs/blob/0.3/src/shared/ntstatus.rs https://github.com/retep998/winapi-rs/blob/0.3/src/shared/nt... You get type safety because you can define the type of constant rather than use some primitive, but there feels like something is something missing (nicer autocompletion, better auto generated documentation, and so on).
- wtetzner 6y agoI would probably wrap constants with the same prefix in a module, but all that really does is make the naming feel nicer, I guess.