http icon indicating copy to clipboard operation
http copied to clipboard

Consider use of #[non_exhaustive]

Open LPardue opened this issue 5 years ago • 5 comments

I'm sure if this is work the effort but about a year ago I tried to add HTTP/3 to the Version enum and we hit the problem with exhaustive matching. That was independently fixed by adding a __NonExhaustive variant see https://github.com/hyperium/http/blob/master/src/version.rs#L52

In Rust 1.40 the #[non-exhaustive] attribute was landed https://blog.rust-lang.org/2019/12/19/Rust-1.40.0.html#[non_exhaustive]-structs,-enums,-and-variants, so is there any benefit switching to that?

LPardue avatar Jan 09 '20 15:01 LPardue

This would need a breaking change release as it would bump the minimum supported Rust version

carllerche avatar Jan 09 '20 15:01 carllerche

Is that a no? 😀

Or does it mean this change can be rolled into a label for the next breaking change release?

No advocating for doing work just for the sake of it. Happy to close the issue if that's the best action.

LPardue avatar Jan 09 '20 16:01 LPardue

We can consider it for the next breaking release.

carllerche avatar Jan 09 '20 16:01 carllerche

I think there are at least two things that could be done without a breaking release:

  • Error, as I mentioned here before seeing this issue: https://github.com/hyperium/http/issues/188#issuecomment-1928426218
  • http::response::Parts, instead of using a dummy private item

tgross35 avatar Feb 05 '24 22:02 tgross35

The MSRV is high enough that #[non_exhaustive] can be used now, right?

riking avatar May 20 '24 17:05 riking