*: Fix clippy warnings (#2615)

This commit is contained in:
Hubert
2022-04-19 12:13:45 +02:00
committed by GitHub
parent 0c1ac781a2
commit 22fbce34d5
16 changed files with 67 additions and 39 deletions

View File

@ -263,7 +263,7 @@ impl DerDecodable<'_> for Asn1SubjectPublicKey {
)));
}
let pk_der: Vec<u8> = object.value().into_iter().skip(1).cloned().collect();
let pk_der: Vec<u8> = object.value().iter().skip(1).cloned().collect();
// We don't parse pk_der further as an ASN.1 RsaPublicKey, since
// we only need the DER encoding for `verify`.
Ok(Self(PublicKey(pk_der)))

View File

@ -94,7 +94,7 @@ impl PeerId {
/// In case the given [`Multiaddr`] ends with `/p2p/<peer-id>`, this function
/// will return the encapsulated [`PeerId`], otherwise it will return `None`.
pub fn try_from_multiaddr(address: &Multiaddr) -> Option<PeerId> {
address.iter().last().map_or(None, |p| match p {
address.iter().last().and_then(|p| match p {
Protocol::P2p(hash) => PeerId::from_multihash(hash).ok(),
_ => None,
})

View File

@ -89,7 +89,7 @@ impl PeerRecord {
};
let envelope = SignedEnvelope::new(
&key,
key,
String::from(DOMAIN_SEP),
PAYLOAD_TYPE.as_bytes().to_vec(),
payload,

View File

@ -358,9 +358,9 @@ impl<T> Sink<T> for Chan<T> {
}
}
impl<T: AsRef<[u8]>> Into<RwStreamSink<Chan<T>>> for Chan<T> {
fn into(self) -> RwStreamSink<Chan<T>> {
RwStreamSink::new(self)
impl<T: AsRef<[u8]>> From<Chan<T>> for RwStreamSink<Chan<T>> {
fn from(channel: Chan<T>) -> RwStreamSink<Chan<T>> {
RwStreamSink::new(channel)
}
}