Skip to content

Commit

Permalink
refactor(lib): use non_exhaustive macro for future field expanding in…
Browse files Browse the repository at this point in the history
…stead of manual implementation
  • Loading branch information
tottoto committed Feb 19, 2024
1 parent c03cc8b commit 62e07da
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/request.rs
Expand Up @@ -165,6 +165,7 @@ pub struct Request<T> {
/// The HTTP request head consists of a method, uri, version, and a set of
/// header fields.
#[derive(Clone)]
#[non_exhaustive]
pub struct Parts {
/// The request's method
pub method: Method,
Expand All @@ -180,8 +181,6 @@ pub struct Parts {

/// The request's extensions
pub extensions: Extensions,

_priv: (),
}

/// An HTTP request builder
Expand Down Expand Up @@ -715,7 +714,6 @@ impl Parts {
version: Version::default(),
headers: HeaderMap::default(),
extensions: Extensions::default(),
_priv: (),
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/response.rs
Expand Up @@ -187,6 +187,7 @@ pub struct Response<T> {
/// The HTTP response head consists of a status, version, and a set of
/// header fields.
#[derive(Clone)]
#[non_exhaustive]
pub struct Parts {
/// The response's status
pub status: StatusCode,
Expand All @@ -199,8 +200,6 @@ pub struct Parts {

/// The response's extensions
pub extensions: Extensions,

_priv: (),
}

/// An HTTP response builder
Expand Down Expand Up @@ -507,7 +506,6 @@ impl Parts {
version: Version::default(),
headers: HeaderMap::default(),
extensions: Extensions::default(),
_priv: (),
}
}
}
Expand All @@ -519,7 +517,6 @@ impl fmt::Debug for Parts {
.field("version", &self.version)
.field("headers", &self.headers)
// omits Extensions because not useful
// omits _priv because not useful
.finish()
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/uri/mod.rs
Expand Up @@ -103,6 +103,7 @@ pub struct Uri {
///
/// This struct is used to provide to and retrieve from a URI.
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct Parts {
/// The scheme component of a URI
pub scheme: Option<Scheme>,
Expand All @@ -112,9 +113,6 @@ pub struct Parts {

/// The origin-form component of a URI
pub path_and_query: Option<PathAndQuery>,

/// Allow extending in the future
_priv: (),
}

/// An error resulting from a failed attempt to construct a URI.
Expand Down Expand Up @@ -814,7 +812,6 @@ impl From<Uri> for Parts {
scheme,
authority,
path_and_query,
_priv: (),
}
}
}
Expand Down

0 comments on commit 62e07da

Please sign in to comment.