Skip to content

Commit 895760f

Browse files
authored
Merge pull request #12 from joshtriplett/simplification
Drop unused return values of TlsListener::configure and TlsListener::connect
2 parents ea41f9f + 0306e91 commit 895760f

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/tls_listener.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<State> TlsListener<State> {
6969
TlsListenerBuilder::new()
7070
}
7171

72-
async fn configure(&mut self) -> io::Result<TlsAcceptor> {
72+
async fn configure(&mut self) -> io::Result<()> {
7373
self.config = match std::mem::take(&mut self.config) {
7474
TlsListenerConfig::Paths { cert, key } => {
7575
let certs = load_certs(&cert)?;
@@ -86,17 +86,17 @@ impl<State> TlsListener<State> {
8686
TlsListenerConfig::Acceptor(TlsAcceptor::from(Arc::new(config)))
8787
}
8888

89-
other => other,
89+
other @ TlsListenerConfig::Acceptor(_) => other,
90+
91+
TlsListenerConfig::Unconfigured => {
92+
return Err(io::Error::new(
93+
io::ErrorKind::Other,
94+
"could not configure tlslistener",
95+
));
96+
}
9097
};
9198

92-
if let TlsListenerConfig::Acceptor(ref a) = self.config {
93-
Ok(a.clone())
94-
} else {
95-
Err(io::Error::new(
96-
io::ErrorKind::Other,
97-
"could not configure tlslistener",
98-
))
99-
}
99+
Ok(())
100100
}
101101

102102
fn acceptor(&self) -> Option<&TlsAcceptor> {
@@ -113,17 +113,12 @@ impl<State> TlsListener<State> {
113113
}
114114
}
115115

116-
async fn connect(&mut self) -> io::Result<&TcpListener> {
116+
async fn connect(&mut self) -> io::Result<()> {
117117
if let TcpConnection::Addrs(addrs) = &self.connection {
118118
let tcp = TcpListener::bind(&addrs[..]).await?;
119119
self.connection = TcpConnection::Connected(tcp);
120120
}
121-
122-
if let TcpConnection::Connected(tcp) = &self.connection {
123-
Ok(tcp)
124-
} else {
125-
unreachable!()
126-
}
121+
Ok(())
127122
}
128123
}
129124

0 commit comments

Comments
 (0)