Skip to content

Commit ff1eec9

Browse files
committed
chore: remove loop that never actually loops reported by cargo clippy
1 parent bcfdc74 commit ff1eec9

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/session/mod.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -475,30 +475,28 @@ impl Session {
475475
hosts: &mut impl Iterator<Item = (&'a str, u16)>,
476476
deadline: &mut Sleep,
477477
) -> Result<(TcpStream, (&'a str, u16)), Error> {
478-
loop {
479-
let addr = match hosts.next() {
480-
None => return Err(Error::NoHosts),
481-
Some(addr) => addr,
482-
};
483-
select! {
484-
_ = unsafe { Pin::new_unchecked(deadline) } => return Err(Error::Timeout),
485-
_ = time::sleep(self.connection_timeout) => {
486-
log::debug!("ZooKeeper fails to connect to {}:{} in {}ms", addr.0, addr.1, self.connection_timeout.as_millis());
487-
return Err(Error::ConnectionLoss)
488-
},
489-
r = TcpStream::connect(addr) => {
490-
return match r {
491-
Err(err) => {
492-
log::debug!("ZooKeeper fails to connect to {}:{} due to {}", addr.0, addr.1, err);
493-
Err(Error::ConnectionLoss)
494-
},
495-
Ok(sock) => {
496-
log::debug!("ZooKeeper succeeds in connectiong to {}:{}", addr.0, addr.1);
497-
Ok((sock, addr))
498-
},
499-
};
500-
},
501-
}
478+
let addr = match hosts.next() {
479+
None => return Err(Error::NoHosts),
480+
Some(addr) => addr,
481+
};
482+
select! {
483+
_ = unsafe { Pin::new_unchecked(deadline) } => Err(Error::Timeout),
484+
_ = time::sleep(self.connection_timeout) => {
485+
log::debug!("ZooKeeper fails to connect to {}:{} in {}ms", addr.0, addr.1, self.connection_timeout.as_millis());
486+
Err(Error::ConnectionLoss)
487+
},
488+
r = TcpStream::connect(addr) => {
489+
match r {
490+
Err(err) => {
491+
log::debug!("ZooKeeper fails to connect to {}:{} due to {}", addr.0, addr.1, err);
492+
Err(Error::ConnectionLoss)
493+
},
494+
Ok(sock) => {
495+
log::debug!("ZooKeeper succeeds in connectiong to {}:{}", addr.0, addr.1);
496+
Ok((sock, addr))
497+
},
498+
}
499+
},
502500
}
503501
}
504502

0 commit comments

Comments
 (0)