From 0d1133ef75a1b6271847d25a1af2119a32f35cd0 Mon Sep 17 00:00:00 2001 From: Niklas Adofsson Date: Thu, 23 Aug 2018 11:53:30 +0200 Subject: [PATCH] Use `rustc-hex v2.0` with explicit types The issue was that the trait `FromHex` has changed and is now using `FromIterator` instead of `FromIterator>` and was `inferred` to `[u8]` instead of `Vec`. Thus, has not compile-time size and won't work! Well, this could be improved to be stack allocated because we know the `size` of the hexstring but in this case I think is sufficient and only used in tests! --- ethbloom/Cargo.toml | 2 +- ethbloom/src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ethbloom/Cargo.toml b/ethbloom/Cargo.toml index 81c49b7..5df4aac 100644 --- a/ethbloom/Cargo.toml +++ b/ethbloom/Cargo.toml @@ -17,7 +17,7 @@ serde = { version = "1.0", optional = true } [dev-dependencies] rand = { version = "0.4" } -rustc-hex = "1.0.0" +rustc-hex = "2.0" [features] default = ["std", "heapsizeof", "serialize", "fixed-hash/libc"] diff --git a/ethbloom/src/lib.rs b/ethbloom/src/lib.rs index 78a8d77..8c59623 100644 --- a/ethbloom/src/lib.rs +++ b/ethbloom/src/lib.rs @@ -7,8 +7,8 @@ //! //! fn main() { //! let bloom: Bloom = "00000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002020000000000000000000000000000000000000000000008000000001000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000".into(); -//! let address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".from_hex().unwrap(); -//! let topic = "02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc".from_hex().unwrap(); +//! let address: Vec = "ef2d6d194084c2de36e0dabfce45d046b37d1106".from_hex().unwrap(); +//! let topic: Vec = "02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc".from_hex().unwrap(); //! //! let mut my_bloom = Bloom::default(); //! assert!(!my_bloom.contains_input(Input::Raw(&address))); @@ -261,8 +261,8 @@ mod tests { #[test] fn it_works() { let bloom: Bloom = "00000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002020000000000000000000000000000000000000000000008000000001000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000".into(); - let address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".from_hex().unwrap(); - let topic = "02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc".from_hex().unwrap(); + let address: Vec = "ef2d6d194084c2de36e0dabfce45d046b37d1106".from_hex().unwrap(); + let topic: Vec = "02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc".from_hex().unwrap(); let mut my_bloom = Bloom::default(); assert!(!my_bloom.contains_input(Input::Raw(&address)));