Merge #432
432: Clippy lints in 1.48 r=koivunej a=koivunej Minor fixes. Co-authored-by: Joonas Koivunen <joonas.koivunen@gmail.com>
This commit is contained in:
commit
d3a3c6921e
@ -136,7 +136,7 @@ fn parse_format(s: &str) -> Result<Vec<FormattedPart>, FormatError> {
|
||||
let remaining = chars.as_str();
|
||||
let end = remaining
|
||||
.find('>')
|
||||
.ok_or_else(|| FormatError::UnterminatedTag(index))?;
|
||||
.ok_or(FormatError::UnterminatedTag(index))?;
|
||||
|
||||
// the use of string indices here is ok as the angle brackets are ascii and
|
||||
// cannot be in the middle of multibyte char boundaries
|
||||
|
@ -129,13 +129,13 @@ where
|
||||
.decode_utf8()
|
||||
.map_err(AddError::InvalidFilename)?;
|
||||
|
||||
let filename = if filename.starts_with('/') {
|
||||
let filename = if let Some(relative) = filename.strip_prefix('/') {
|
||||
// normalize single first slash; seems similar to what js-ipfs does: filesystem
|
||||
// test cases post with paths '/some-directory/...' and others post with
|
||||
// 'some-directory/...'.
|
||||
|
||||
// since slash is a single code point, we can just do
|
||||
filename[1..].to_owned()
|
||||
relative.to_owned()
|
||||
} else {
|
||||
filename.into_owned()
|
||||
};
|
||||
|
@ -44,8 +44,8 @@ impl Future for DnsLinkFuture {
|
||||
let txt = record?;
|
||||
let bytes: &[u8] = txt.data().as_flat_slice().unwrap_or(b"");
|
||||
let string = String::from_utf8_lossy(&bytes).to_string();
|
||||
if string.starts_with("dnslink=") {
|
||||
let path = IpfsPath::from_str(&string[8..])?;
|
||||
if let Some(path) = string.strip_prefix("dnslink=") {
|
||||
let path = IpfsPath::from_str(path)?;
|
||||
return Poll::Ready(Ok(path));
|
||||
}
|
||||
}
|
||||
|
@ -919,7 +919,7 @@ impl<Types: IpfsTypes> Ipfs<Types> {
|
||||
.await?;
|
||||
|
||||
match rx.await? {
|
||||
Either::Left(addrs) if !addrs.is_empty() => return Ok(addrs),
|
||||
Either::Left(addrs) if !addrs.is_empty() => Ok(addrs),
|
||||
Either::Left(_) => unreachable!(),
|
||||
Either::Right(future) => {
|
||||
future.await?;
|
||||
@ -932,8 +932,8 @@ impl<Types: IpfsTypes> Ipfs<Types> {
|
||||
.await?;
|
||||
|
||||
match rx.await? {
|
||||
Either::Left(addrs) if !addrs.is_empty() => return Ok(addrs),
|
||||
_ => return Err(anyhow!("couldn't find peer {}", peer_id)),
|
||||
Either::Left(addrs) if !addrs.is_empty() => Ok(addrs),
|
||||
_ => Err(anyhow!("couldn't find peer {}", peer_id)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ pub struct Behaviour<Types: IpfsTypes> {
|
||||
pub enum KadResult {
|
||||
/// The query has been exhausted.
|
||||
Complete,
|
||||
/// The query successfully returns `GetClosestPeers` or `GetProviders` results.
|
||||
/// The query successfully returns `GetClosestPeers` or `GetProviders` results.
|
||||
Peers(Vec<PeerId>),
|
||||
/// The query successfully returns a `GetRecord` result.
|
||||
Records(Vec<Record>),
|
||||
@ -333,7 +333,6 @@ impl<Types: IpfsTypes> NetworkBehaviourEventProcess<BitswapEvent> for Behaviour<
|
||||
peer_id.to_base58(),
|
||||
e
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -393,7 +393,7 @@ fn update_full_path(
|
||||
|
||||
if let Some(name) = name {
|
||||
if !full_path.is_empty() {
|
||||
full_path.push_str("/");
|
||||
full_path.push('/');
|
||||
}
|
||||
full_path.push_str(name);
|
||||
*old_depth += 1;
|
||||
|
Loading…
Reference in New Issue
Block a user