Replies: 5 comments 7 replies
-
The more I think about it, the more I like this idea. I'll bring it up in today's maintainer call: #4556 |
Beta Was this translation helpful? Give feedback.
-
Here is the full description of this feature: https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute One thing that is nice and I didn't know is that it can also be applied to As an example, if we would have Similiarly, if all |
Beta Was this translation helpful? Give feedback.
-
Perhaps a suitable policy would be to at least apply this to enums from |
Beta Was this translation helpful? Give feedback.
-
I am in favor of the proposal. I think we should consider Another con: in case we ever have a semantically breaking change, we can no longer force a user to handle the case of the change by adding a new enum variant. Though off the top of my head, I can not think of such a need in the past. |
Beta Was this translation helpful? Give feedback.
-
draft PR #4581 submitted |
Beta Was this translation helpful? Give feedback.
-
While working on PR #4503 a short discussion came up about how adding an emitted event to the Kademlia protocol was a breaking change. I wondered out loud to @thomaseizinger if we should also add
#[non_exhaustive]
to the eventenum
as part of this breaking change so that in the future it won't be a breaking change to add more events. I brought the discussion here to surface it and build some consensus.Proposal:
#[non_exhaustive]
to the eventenum
for protocols as a one-time breaking change.Pros:
enum
in the future won't trigger any compile warnings._ => {}
Cons:
match
es against the eventenum
must have a wildcard arm:_ => {}
enum
is to enable a—currently unstable—lint check: Tracking Issue for#![feature(non_exhaustive_omitted_patterns_lint)]
rust-lang/rust#89554Thoughts? @thomaseizinger mentioned that we had considered it before but I couldn't find any previous posts in theses discussions or on discuss.libp2p.io.
Beta Was this translation helpful? Give feedback.
All reactions