Skip to content

Commit 891a9ba

Browse files
committed
clippy fixes
Signed-off-by: Dave Huseby <[email protected]>
1 parent d4daf28 commit 891a9ba

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "multicid"
3-
version = "1.0.4"
3+
version = "1.0.5"
44
edition = "2021"
55
authors = ["Dave Grantham <[email protected]>"]
66
description = "Multicodec compatible content identifier implementation"

src/cid.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ impl EncodingInfo for Cid {
6666
}
6767
}
6868

69-
impl Into<Vec<u8>> for Cid {
70-
fn into(self) -> Vec<u8> {
69+
impl From<Cid> for Vec<u8> {
70+
fn from(cid: Cid) -> Self {
7171
let mut v = Vec::default();
7272
// if we're not a v0 Cid, add in the version and the encoding codec
73-
if self.codec() != Codec::Identity {
73+
if cid.codec() != Codec::Identity {
7474
// add in the Cid codec
75-
v.append(&mut self.codec.clone().into());
75+
v.append(&mut cid.codec.into());
7676
// add in the target encoding codec
77-
v.append(&mut self.target_codec.clone().into());
77+
v.append(&mut cid.target_codec.into());
7878
}
7979
// add in the multihash data
80-
v.append(&mut self.hash.clone().into());
80+
v.append(&mut cid.hash.into());
8181
v
8282
}
8383
}
@@ -211,14 +211,14 @@ impl Builder {
211211
}
212212
Ok(EncodedCid::new(
213213
self.base_encoding
214-
.unwrap_or_else(|| Cid::preferred_encoding()),
214+
.unwrap_or_else(Cid::preferred_encoding),
215215
self.try_build()?,
216216
))
217217
}
218218

219219
/// build the cid
220220
pub fn try_build(&self) -> Result<Cid, Error> {
221-
if let Some(codec) = self.codec.clone() {
221+
if let Some(codec) = self.codec {
222222
// build a v1 or later Cid
223223
Ok(Cid {
224224
codec,

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Idnetifier: Apache-2.0
22

3-
//!
3+
//! multicid
44
#![warn(missing_docs)]
55
#![deny(
66
trivial_casts,

src/serde/de.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<'de> Deserialize<'de> for Cid {
1717
where
1818
D: Deserializer<'de>,
1919
{
20-
const FIELDS: &'static [&'static str] = &["version", "encoding", "hash"];
20+
const FIELDS: &[&str] = &["version", "encoding", "hash"];
2121

2222
#[derive(Deserialize)]
2323
#[serde(field_identifier, rename_all = "lowercase")]
@@ -131,7 +131,7 @@ impl<'de> Deserialize<'de> for Vlad {
131131
where
132132
D: Deserializer<'de>,
133133
{
134-
const FIELDS: &'static [&'static str] = &["nonce", "cid"];
134+
const FIELDS: &[&str] = &["nonce", "cid"];
135135

136136
#[derive(Deserialize)]
137137
#[serde(field_identifier, rename_all = "lowercase")]

src/vlad.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ impl EncodingInfo for Vlad {
7272
}
7373
}
7474

75-
impl Into<Vec<u8>> for Vlad {
76-
fn into(self) -> Vec<u8> {
75+
impl From<Vlad> for Vec<u8> {
76+
fn from(vlad: Vlad) -> Vec<u8> {
7777
let mut v = Vec::default();
7878
// add the sigil
7979
v.append(&mut SIGIL.into());
8080
// add the nonce
81-
v.append(&mut self.nonce.clone().into());
81+
v.append(&mut vlad.nonce.into());
8282
// add the cid
83-
v.append(&mut self.cid.clone().into());
83+
v.append(&mut vlad.cid.into());
8484
v
8585
}
8686
}
@@ -168,7 +168,7 @@ impl Builder {
168168
pub fn try_build_encoded(&self) -> Result<EncodedVlad, Error> {
169169
Ok(EncodedVlad::new(
170170
self.base_encoding
171-
.unwrap_or_else(|| Vlad::preferred_encoding()),
171+
.unwrap_or_else(Vlad::preferred_encoding),
172172
self.try_build()?,
173173
))
174174
}

0 commit comments

Comments
 (0)