Skip to content

Commit

Permalink
Address some minor clippy warnings. (#1868)
Browse files Browse the repository at this point in the history
  • Loading branch information
romanb authored and Roman S. Borschel committed Dec 3, 2020
1 parent 4e84b12 commit 54c870b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/src/connection/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ where
I: Iterator<Item = ConnectionId>
{
/// 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() {
if self.pool.manager.is_established(&id) { // (*)
Expand Down
12 changes: 6 additions & 6 deletions core/src/network/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ where

/// Obtains a dialing attempt to the peer by connection ID of
/// the current connection attempt.
pub fn attempt<'b>(&'b mut self, id: ConnectionId)
-> Option<DialingAttempt<'b, TInEvent>>
pub fn attempt(&mut self, id: ConnectionId)
-> Option<DialingAttempt<'_, TInEvent>>
{
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) {
Expand All @@ -446,8 +446,8 @@ where
}

/// Gets an iterator over all dialing (i.e. pending outgoing) connections to the peer.
pub fn attempts<'b>(&'b mut self)
-> DialingAttemptIter<'b,
pub fn attempts(&mut self)
-> DialingAttemptIter<'_,
TInEvent,
TOutEvent,
THandler,
Expand All @@ -460,8 +460,8 @@ where
/// Obtains some dialing connection to the peer.
///
/// At least one dialing connection is guaranteed to exist on a `DialingPeer`.
pub fn some_attempt<'b>(&'b mut self)
-> DialingAttempt<'b, TInEvent>
pub fn some_attempt(&mut self)
-> DialingAttempt<'_, TInEvent>
{
self.attempts()
.into_first()
Expand Down
27 changes: 14 additions & 13 deletions misc/multiaddr/src/from_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ fn from_url_inner_http_ws(url: url::Url, lossy: bool) -> std::result::Result<Mul
return Err(FromUrlErr::BadUrl);
};

if !lossy {
if !url.username().is_empty() || url.password().is_some() ||
(lost_path && url.path() != "/" && !url.path().is_empty()) ||
url.query().is_some() || url.fragment().is_some()
{
return Err(FromUrlErr::InformationLoss);
}
if !lossy && (
!url.username().is_empty() ||
url.password().is_some() ||
(lost_path && url.path() != "/" && !url.path().is_empty()) ||
url.query().is_some() || url.fragment().is_some()
) {
return Err(FromUrlErr::InformationLoss);
}

Ok(iter::once(ip)
Expand All @@ -104,12 +104,13 @@ 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")
};

if !lossy {
if !url.username().is_empty() || url.password().is_some() ||
url.query().is_some() || url.fragment().is_some()
{
return Err(FromUrlErr::InformationLoss);
}
if !lossy && (
!url.username().is_empty() ||
url.password().is_some() ||
url.query().is_some() ||
url.fragment().is_some()
) {
return Err(FromUrlErr::InformationLoss);
}

Ok(Multiaddr::from(protocol))
Expand Down

0 comments on commit 54c870b

Please sign in to comment.