@@ -66,18 +66,18 @@ impl EncodingInfo for Cid {
66
66
}
67
67
}
68
68
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 {
71
71
let mut v = Vec :: default ( ) ;
72
72
// 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 {
74
74
// add in the Cid codec
75
- v. append ( & mut self . codec . clone ( ) . into ( ) ) ;
75
+ v. append ( & mut cid . codec . into ( ) ) ;
76
76
// add in the target encoding codec
77
- v. append ( & mut self . target_codec . clone ( ) . into ( ) ) ;
77
+ v. append ( & mut cid . target_codec . into ( ) ) ;
78
78
}
79
79
// add in the multihash data
80
- v. append ( & mut self . hash . clone ( ) . into ( ) ) ;
80
+ v. append ( & mut cid . hash . into ( ) ) ;
81
81
v
82
82
}
83
83
}
@@ -211,14 +211,14 @@ impl Builder {
211
211
}
212
212
Ok ( EncodedCid :: new (
213
213
self . base_encoding
214
- . unwrap_or_else ( || Cid :: preferred_encoding ( ) ) ,
214
+ . unwrap_or_else ( Cid :: preferred_encoding) ,
215
215
self . try_build ( ) ?,
216
216
) )
217
217
}
218
218
219
219
/// build the cid
220
220
pub fn try_build ( & self ) -> Result < Cid , Error > {
221
- if let Some ( codec) = self . codec . clone ( ) {
221
+ if let Some ( codec) = self . codec {
222
222
// build a v1 or later Cid
223
223
Ok ( Cid {
224
224
codec,
0 commit comments