chore: replace manual impl of #[non_exhaustive] for InvalidHeaderName (#981)

This commit is contained in:
Paolo Barbolini
2024-08-29 05:43:23 +02:00
committed by GitHub
parent f7a1b790df
commit ca405040ae

View File

@@ -157,18 +157,9 @@ impl Display for Headers {
/// A possible error when converting a `HeaderName` from another type. /// A possible error when converting a `HeaderName` from another type.
// comes from `http` crate // comes from `http` crate
#[allow(missing_copy_implementations)] #[allow(missing_copy_implementations)]
#[derive(Clone)] #[derive(Debug, Clone)]
pub struct InvalidHeaderName { #[non_exhaustive]
_priv: (), pub struct InvalidHeaderName;
}
impl fmt::Debug for InvalidHeaderName {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("InvalidHeaderName")
// skip _priv noise
.finish()
}
}
impl fmt::Display for InvalidHeaderName { impl fmt::Display for InvalidHeaderName {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -189,7 +180,7 @@ impl HeaderName {
{ {
Ok(Self(Cow::Owned(ascii))) Ok(Self(Cow::Owned(ascii)))
} else { } else {
Err(InvalidHeaderName { _priv: () }) Err(InvalidHeaderName)
} }
} }