chore: satisfy clippy 1.99
CI's Lint job runs current stable, which gained two lints that failed develop: `redundant_else` in `Client::login`, now written with early returns, and `assert_is_empty`, which asks every `assert!(x.is_empty())` in the tests to become `assert_eq!(x, [] as [T; 0])`. The second trades a clear check for a type-cast chore, so it joins the curated allow-list.
This commit is contained in:
@@ -53,6 +53,9 @@ significant_drop_tightening = "allow"
|
|||||||
# Subjective nursery lint: the suggested map_or/map_or_else rewrites read worse
|
# Subjective nursery lint: the suggested map_or/map_or_else rewrites read worse
|
||||||
# than the explicit if let/match they replace.
|
# than the explicit if let/match they replace.
|
||||||
option_if_let_else = "allow"
|
option_if_let_else = "allow"
|
||||||
|
# `assert!(x.is_empty())` in tests is fine; the suggested
|
||||||
|
# `assert_eq!(x, [] as [T; 0])` only trades a clear check for a type-cast chore.
|
||||||
|
assert_is_empty = "allow"
|
||||||
# The MD5 round functions use the conventional a/b/c/d register names from the
|
# The MD5 round functions use the conventional a/b/c/d register names from the
|
||||||
# RFC 1321 reference implementation.
|
# RFC 1321 reference implementation.
|
||||||
many_single_char_names = "allow"
|
many_single_char_names = "allow"
|
||||||
|
|||||||
@@ -209,33 +209,33 @@ impl Client {
|
|||||||
/// control.
|
/// control.
|
||||||
pub fn login(&self) -> Result<bool> {
|
pub fn login(&self) -> Result<bool> {
|
||||||
info!("Logging in as {}", self.username);
|
info!("Logging in as {}", self.username);
|
||||||
if let Some(handle) = &self.server_handle
|
let Some(handle) = &self.server_handle else {
|
||||||
&& !self.cancel.is_cancelled()
|
return Err(SoulseekRs::NotConnected);
|
||||||
{
|
};
|
||||||
let (tx, rx) = std::sync::mpsc::channel();
|
if self.cancel.is_cancelled() {
|
||||||
let _ = handle.send(ServerMessage::Login {
|
return Err(SoulseekRs::NotConnected);
|
||||||
username: self.username.clone(),
|
}
|
||||||
password: self.password.clone(),
|
let (tx, rx) = std::sync::mpsc::channel();
|
||||||
version: self.version,
|
let _ = handle.send(ServerMessage::Login {
|
||||||
response: tx,
|
username: self.username.clone(),
|
||||||
});
|
password: self.password.clone(),
|
||||||
|
version: self.version,
|
||||||
|
response: tx,
|
||||||
|
});
|
||||||
|
|
||||||
let deadline = Instant::now() + LOGIN_RESPONSE_TIMEOUT;
|
let deadline = Instant::now() + LOGIN_RESPONSE_TIMEOUT;
|
||||||
loop {
|
loop {
|
||||||
match rx.recv_timeout(LOGIN_POLL_INTERVAL) {
|
match rx.recv_timeout(LOGIN_POLL_INTERVAL) {
|
||||||
Ok(result) => return result,
|
Ok(result) => return result,
|
||||||
Err(RecvTimeoutError::Timeout)
|
Err(RecvTimeoutError::Timeout)
|
||||||
if self.cancel.is_cancelled() =>
|
if self.cancel.is_cancelled() =>
|
||||||
{
|
{
|
||||||
return Err(SoulseekRs::NotConnected);
|
return Err(SoulseekRs::NotConnected);
|
||||||
}
|
|
||||||
Err(RecvTimeoutError::Timeout)
|
|
||||||
if Instant::now() < deadline => {}
|
|
||||||
Err(_) => return Err(SoulseekRs::Timeout),
|
|
||||||
}
|
}
|
||||||
|
Err(RecvTimeoutError::Timeout) if Instant::now() < deadline => {
|
||||||
|
}
|
||||||
|
Err(_) => return Err(SoulseekRs::Timeout),
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Err(SoulseekRs::NotConnected)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user