diff --git a/Cargo.toml b/Cargo.toml index d8d2fe3b..a033d503 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,12 +33,12 @@ strobe = ["strobe-rs"] [dependencies] generic-array = "0.14.4" -parity-scale-codec = { version = "1.3.5", optional = true, default-features = false, features = ["derive"] } +parity-scale-codec = { version = "2.1.1", default-features = false, features = ["derive"], optional = true } quickcheck = { version = "0.9.2", optional = true } rand = { version = "0.7.3", optional = true } -serde = { version = "1.0.116", optional = true, default-features = false, features = ["derive"] } -multihash-derive = { version = "^0.7.1", path = "derive", default-features = false, optional = true } -unsigned-varint = "0.7.0" +serde = { version = "1.0.116", default-features = false, features = ["derive"], optional = true } +multihash-derive = { version = "0.7.1", path = "derive", default-features = false, optional = true } +unsigned-varint = { version = "0.7.0", default-features = false } blake2b_simd = { version = "0.5.10", default-features = false, optional = true } blake2s_simd = { version = "0.5.10", default-features = false, optional = true } @@ -47,13 +47,11 @@ digest = { version = "0.9.0", default-features = false, optional = true } sha-1 = { version = "0.9.1", default-features = false, optional = true } sha-2 = { version = "0.9.0", default-features = false, optional = true, package = "sha2" } sha-3 = { version = "0.9.0", default-features = false, optional = true, package = "sha3" } -strobe-rs = { version = "0.6.2", optional = true } +strobe-rs = { version = "0.6.2", default-features = false, optional = true } [dev-dependencies] criterion = "0.3.3" hex = "0.4.2" -quickcheck = "0.9.2" -rand = "0.7.3" serde_json = "1.0.58" [[bench]] diff --git a/src/multihash.rs b/src/multihash.rs index 50339710..7bcc3830 100644 --- a/src/multihash.rs +++ b/src/multihash.rs @@ -181,12 +181,12 @@ impl From> for Vec { #[cfg(feature = "scale-codec")] impl parity_scale_codec::Encode for Multihash { - fn encode_to(&self, dest: &mut EncOut) { + fn encode_to(&self, dest: &mut EncOut) { let mut digest = [0; 32]; digest.copy_from_slice(&self.digest); - dest.push(&self.code); - dest.push(&self.size); - dest.push(&digest); + self.code.encode_to(dest); + self.size.encode_to(dest); + digest.encode_to(dest); } } @@ -211,12 +211,12 @@ impl parity_scale_codec::Decode for Multihash { #[cfg(feature = "scale-codec")] impl parity_scale_codec::Encode for Multihash { - fn encode_to(&self, dest: &mut EncOut) { + fn encode_to(&self, dest: &mut EncOut) { let mut digest = [0; 64]; digest.copy_from_slice(&self.digest); - dest.push(&self.code); - dest.push(&self.size); - dest.push(&digest); + self.code.encode_to(dest); + self.size.encode_to(dest); + digest.encode_to(dest); } }