From c2119e2382223458bd94b19d63e61d5532a2d7bf Mon Sep 17 00:00:00 2001 From: tottoto Date: Sat, 17 Feb 2024 05:29:35 +0900 Subject: [PATCH] refactor(lib): use non_exhaustive macro for future field expanding instead of manual implementation --- src/request.rs | 4 +--- src/response.rs | 5 +---- src/uri/mod.rs | 5 +---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/request.rs b/src/request.rs index d4c5bf54..09ddf614 100644 --- a/src/request.rs +++ b/src/request.rs @@ -165,6 +165,7 @@ pub struct Request { /// 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, @@ -180,8 +181,6 @@ pub struct Parts { /// The request's extensions pub extensions: Extensions, - - _priv: (), } /// An HTTP request builder @@ -715,7 +714,6 @@ impl Parts { version: Version::default(), headers: HeaderMap::default(), extensions: Extensions::default(), - _priv: (), } } } diff --git a/src/response.rs b/src/response.rs index 312cc5f8..b418129a 100644 --- a/src/response.rs +++ b/src/response.rs @@ -187,6 +187,7 @@ pub struct Response { /// 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, @@ -199,8 +200,6 @@ pub struct Parts { /// The response's extensions pub extensions: Extensions, - - _priv: (), } /// An HTTP response builder @@ -507,7 +506,6 @@ impl Parts { version: Version::default(), headers: HeaderMap::default(), extensions: Extensions::default(), - _priv: (), } } } @@ -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() } } diff --git a/src/uri/mod.rs b/src/uri/mod.rs index 767f0743..caa797ac 100644 --- a/src/uri/mod.rs +++ b/src/uri/mod.rs @@ -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, @@ -112,9 +113,6 @@ pub struct Parts { /// The origin-form component of a URI pub path_and_query: Option, - - /// Allow extending in the future - _priv: (), } /// An error resulting from a failed attempt to construct a URI. @@ -814,7 +812,6 @@ impl From for Parts { scheme, authority, path_and_query, - _priv: (), } } }