Skip to content

Commit bc9a86f

Browse files
authored
refactor(lib): use non_exhaustive attribute (#3420)
1 parent 12ab310 commit bc9a86f

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

src/client/conn/http1.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct SendRequest<B> {
2929
/// This allows taking apart a `Connection` at a later time, in order to
3030
/// reclaim the IO object, and additional related pieces.
3131
#[derive(Debug)]
32+
#[non_exhaustive]
3233
pub struct Parts<T> {
3334
/// The original IO object used in the handshake.
3435
pub io: T,
@@ -41,7 +42,6 @@ pub struct Parts<T> {
4142
/// You will want to check for any existing bytes if you plan to continue
4243
/// communicating on the IO object.
4344
pub read_buf: Bytes,
44-
_inner: (),
4545
}
4646

4747
/// A future that processes all HTTP state for the IO object.
@@ -68,11 +68,7 @@ where
6868
/// Only works for HTTP/1 connections. HTTP/2 connections will panic.
6969
pub fn into_parts(self) -> Parts<T> {
7070
let (io, read_buf, _) = self.inner.into_inner();
71-
Parts {
72-
io,
73-
read_buf,
74-
_inner: (),
75-
}
71+
Parts { io, read_buf }
7672
}
7773

7874
/// Poll the connection for completion, but without calling `shutdown`
@@ -589,11 +585,7 @@ mod upgrades {
589585
match ready!(Pin::new(&mut self.inner.as_mut().unwrap().inner).poll(cx)) {
590586
Ok(proto::Dispatched::Shutdown) => Poll::Ready(Ok(())),
591587
Ok(proto::Dispatched::Upgrade(pending)) => {
592-
let Parts {
593-
io,
594-
read_buf,
595-
_inner,
596-
} = self.inner.take().unwrap().into_parts();
588+
let Parts { io, read_buf } = self.inner.take().unwrap().into_parts();
597589
pending.fulfill(Upgraded::new(io, read_buf));
598590
Poll::Ready(Ok(()))
599591
}

src/server/conn/http1.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub struct Builder {
8686
/// This allows taking apart a `Connection` at a later time, in order to
8787
/// reclaim the IO object, and additional related pieces.
8888
#[derive(Debug)]
89+
#[non_exhaustive]
8990
pub struct Parts<T, S> {
9091
/// The original IO object used in the handshake.
9192
pub io: T,
@@ -100,7 +101,6 @@ pub struct Parts<T, S> {
100101
pub read_buf: Bytes,
101102
/// The `Service` used to serve this connection.
102103
pub service: S,
103-
_inner: (),
104104
}
105105

106106
// ===== impl Connection =====
@@ -151,7 +151,6 @@ where
151151
io,
152152
read_buf,
153153
service: dispatch.into_service(),
154-
_inner: (),
155154
}
156155
}
157156

src/upgrade.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub struct OnUpgrade {
7979
/// Includes the original IO type, and a read buffer of bytes that the
8080
/// HTTP state machine may have already read before completing an upgrade.
8181
#[derive(Debug)]
82+
#[non_exhaustive]
8283
pub struct Parts<T> {
8384
/// The original IO object used before the upgrade.
8485
pub io: T,
@@ -91,7 +92,6 @@ pub struct Parts<T> {
9192
/// You will want to check for any existing bytes if you plan to continue
9293
/// communicating on the IO object.
9394
pub read_buf: Bytes,
94-
_inner: (),
9595
}
9696

9797
/// Gets a pending HTTP upgrade from this message.
@@ -154,7 +154,6 @@ impl Upgraded {
154154
Ok(t) => Ok(Parts {
155155
io: *t,
156156
read_buf: buf,
157-
_inner: (),
158157
}),
159158
Err(io) => Err(Upgraded {
160159
io: Rewind::new_buffered(io, buf),

0 commit comments

Comments
 (0)