Add standard Rust attributes.#24
Conversation
Signed-off-by: Yaroslav Skopets <yaroslav@tetrate.io>
e3ad939 to
d0b5d8d
Compare
|
While technically correct, I'm wondering why do you need Also, once we move to the new ABI, those values will be broken in non-backwards-compatible way, so I'm not sure if adding those guarantees and attributes now is such a good idea. |
|
It's about reserving a room for changes that otherwise would be backwards incompatible. The problem comes form Without You will have to do a major release of the library to stick to semantic versioning. |
|
@yskopets I don't think we need non-exaustive for all enums, for some of them it doesn't make sense. If ABI changes, those match statements need to be rewritten or it will break at runtime. |
PiotrSikora
left a comment
There was a problem hiding this comment.
Regarding #[non_exhaustive], I think that we could add it for now (but we should remove it once the ABI is frozen), though it doesn't really makes sense to do an exhaustive match on any of the enums defined here (other than the LogLevel).
Regarding the other traits, Copy and Clone are fine, but I'm a bit confused as to why do we need PartialEq, Eq and Hash. Could you elaborate on each one?
Overall, implementing these traits is advised by the Rust API Guidelines (interoperability). Practically, #[test]
fn test_log_level_eq() {
assert_ne!(LogLevel::Critical, LogLevel::Debug);
}All 3 |
…e-non-exhaustive Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Summary
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]