Address some minor clippy warnings. (#1868)

This commit is contained in:
Roman Borschel
2020-11-30 16:45:40 +01:00
committed by GitHub
parent afc5d0ef82
commit 2cd2e6d654
3 changed files with 21 additions and 20 deletions

View File

@ -842,7 +842,7 @@ where
I: Iterator<Item = ConnectionId> I: Iterator<Item = ConnectionId>
{ {
/// Obtains the next connection, if any. /// Obtains the next connection, if any.
pub fn next<'b>(&'b mut self) -> Option<EstablishedConnection<'b, TInEvent>> pub fn next(&mut self) -> Option<EstablishedConnection<'_, TInEvent>>
{ {
while let Some(id) = self.ids.next() { while let Some(id) = self.ids.next() {
if self.pool.manager.is_established(&id) { // (*) if self.pool.manager.is_established(&id) { // (*)

View File

@ -432,8 +432,8 @@ where
/// Obtains a dialing attempt to the peer by connection ID of /// Obtains a dialing attempt to the peer by connection ID of
/// the current connection attempt. /// the current connection attempt.
pub fn attempt<'b>(&'b mut self, id: ConnectionId) pub fn attempt(&mut self, id: ConnectionId)
-> Option<DialingAttempt<'b, TInEvent>> -> Option<DialingAttempt<'_, TInEvent>>
{ {
if let hash_map::Entry::Occupied(attempts) = self.network.dialing.entry(self.peer_id.clone()) { if let hash_map::Entry::Occupied(attempts) = self.network.dialing.entry(self.peer_id.clone()) {
if let Some(pos) = attempts.get().iter().position(|s| s.current.0 == id) { if let Some(pos) = attempts.get().iter().position(|s| s.current.0 == id) {
@ -446,8 +446,8 @@ where
} }
/// Gets an iterator over all dialing (i.e. pending outgoing) connections to the peer. /// Gets an iterator over all dialing (i.e. pending outgoing) connections to the peer.
pub fn attempts<'b>(&'b mut self) pub fn attempts(&mut self)
-> DialingAttemptIter<'b, -> DialingAttemptIter<'_,
TInEvent, TInEvent,
TOutEvent, TOutEvent,
THandler, THandler,
@ -460,8 +460,8 @@ where
/// Obtains some dialing connection to the peer. /// Obtains some dialing connection to the peer.
/// ///
/// At least one dialing connection is guaranteed to exist on a `DialingPeer`. /// At least one dialing connection is guaranteed to exist on a `DialingPeer`.
pub fn some_attempt<'b>(&'b mut self) pub fn some_attempt(&mut self)
-> DialingAttempt<'b, TInEvent> -> DialingAttempt<'_, TInEvent>
{ {
self.attempts() self.attempts()
.into_first() .into_first()

View File

@ -82,14 +82,14 @@ fn from_url_inner_http_ws(url: url::Url, lossy: bool) -> std::result::Result<Mul
return Err(FromUrlErr::BadUrl); return Err(FromUrlErr::BadUrl);
}; };
if !lossy { if !lossy && (
if !url.username().is_empty() || url.password().is_some() || !url.username().is_empty() ||
url.password().is_some() ||
(lost_path && url.path() != "/" && !url.path().is_empty()) || (lost_path && url.path() != "/" && !url.path().is_empty()) ||
url.query().is_some() || url.fragment().is_some() url.query().is_some() || url.fragment().is_some()
{ ) {
return Err(FromUrlErr::InformationLoss); return Err(FromUrlErr::InformationLoss);
} }
}
Ok(iter::once(ip) Ok(iter::once(ip)
.chain(iter::once(port)) .chain(iter::once(port))
@ -104,13 +104,14 @@ fn from_url_inner_path(url: url::Url, lossy: bool) -> std::result::Result<Multia
_ => unreachable!("We only call this function for one of the given schemes; qed") _ => unreachable!("We only call this function for one of the given schemes; qed")
}; };
if !lossy { if !lossy && (
if !url.username().is_empty() || url.password().is_some() || !url.username().is_empty() ||
url.query().is_some() || url.fragment().is_some() url.password().is_some() ||
{ url.query().is_some() ||
url.fragment().is_some()
) {
return Err(FromUrlErr::InformationLoss); return Err(FromUrlErr::InformationLoss);
} }
}
Ok(Multiaddr::from(protocol)) Ok(Multiaddr::from(protocol))
} }