chore: Revert "use #[non_exhaustive] instead of private unit field" (#3323)

This reverts commit 575938d457.
This commit is contained in:
Taiki Endo
2020-12-23 08:27:58 -08:00
committed by GitHub
parent 575938d457
commit ce0e9c67cf
15 changed files with 55 additions and 43 deletions
+8 -3
View File
@@ -24,8 +24,7 @@ pin_project! {
/// Error returned by `Timeout`.
#[derive(Debug, PartialEq)]
#[non_exhaustive]
pub struct Elapsed;
pub struct Elapsed(());
impl<S: Stream> Timeout<S> {
pub(super) fn new(stream: S, duration: Duration) -> Self {
@@ -62,7 +61,7 @@ impl<S: Stream> Stream for Timeout<S> {
if *me.poll_deadline {
ready!(me.deadline.poll(cx));
*me.poll_deadline = false;
return Poll::Ready(Some(Err(Elapsed)));
return Poll::Ready(Some(Err(Elapsed::new())));
}
Poll::Pending
@@ -75,6 +74,12 @@ impl<S: Stream> Stream for Timeout<S> {
// ===== impl Elapsed =====
impl Elapsed {
pub(crate) fn new() -> Self {
Elapsed(())
}
}
impl fmt::Display for Elapsed {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
"deadline has elapsed".fmt(fmt)