Update uint to 0.6
This commit is contained in:
parent
2c5505f03f
commit
4dd9571fff
|
@ -7,10 +7,9 @@ homepage = "https://github.com/paritytech/primitives"
|
|||
description = "Ethereum types"
|
||||
|
||||
[dependencies]
|
||||
crunchy = { version = "0.2", default-features = false }
|
||||
ethbloom = { path = "../ethbloom", version = "0.6", default-features = false }
|
||||
fixed-hash = { version = "0.3", default-features = false, features = ["byteorder", "rustc-hex"] }
|
||||
uint = { version = "0.5", default-features = false }
|
||||
uint = { version = "0.6", default-features = false }
|
||||
primitive-types = { version = "0.1", features = ["rlp", "byteorder", "rustc-hex"], default-features = false }
|
||||
impl-serde = { version = "0.1", default-features = false, optional = true }
|
||||
impl-rlp = { version = "0.1", default-features = false }
|
||||
|
@ -20,6 +19,6 @@ serde_json = "1.0"
|
|||
|
||||
[features]
|
||||
default = ["std", "heapsize", "serialize"]
|
||||
std = ["uint/std", "fixed-hash/std", "ethbloom/std", "crunchy/std", "primitive-types/std"]
|
||||
std = ["uint/std", "fixed-hash/std", "ethbloom/std", "primitive-types/std"]
|
||||
heapsize = ["uint/heapsize", "primitive-types/heapsize", "fixed-hash/heapsize", "ethbloom/heapsize"]
|
||||
serialize = ["std", "impl-serde", "primitive-types/serde", "ethbloom/serialize"]
|
||||
|
|
|
@ -57,7 +57,7 @@ impl_uint_conversions!(H512, U512);
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{H160, H256};
|
||||
use super::{H160, H256, BigEndianHash};
|
||||
use serde_json as ser;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#[cfg(feature = "std")]
|
||||
extern crate core;
|
||||
#[macro_use]
|
||||
extern crate crunchy;
|
||||
#[macro_use]
|
||||
extern crate uint as uint_crate;
|
||||
#[macro_use]
|
||||
extern crate fixed_hash;
|
||||
|
|
|
@ -1,58 +1,12 @@
|
|||
construct_uint!(U64, 1);
|
||||
construct_uint! {
|
||||
/// Unsigned 64-bit integer.
|
||||
pub struct U64(1);
|
||||
}
|
||||
impl_uint_rlp!(U64, 1);
|
||||
#[cfg(feature = "serialize")] impl_uint_serde!(U64, 1);
|
||||
|
||||
construct_uint!(U128, 2);
|
||||
impl_uint_rlp!(U128, 2);
|
||||
#[cfg(feature = "serialize")] impl_uint_serde!(U128, 2);
|
||||
pub use primitive_types::{U128, U256, U512};
|
||||
|
||||
pub use primitive_types::{U256, U512};
|
||||
|
||||
impl From<U256> for U128 {
|
||||
fn from(value: U256) -> U128 {
|
||||
let U256(ref arr) = value;
|
||||
if arr[2] | arr[3] != 0 {
|
||||
panic!("From<U256> for U128: encountered overflow")
|
||||
}
|
||||
let mut ret = [0; 2];
|
||||
ret[0] = arr[0];
|
||||
ret[1] = arr[1];
|
||||
U128(ret)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U512> for U128 {
|
||||
fn from(value: U512) -> U128 {
|
||||
let U512(ref arr) = value;
|
||||
if arr[2] | arr[3] | arr[4] | arr[5] | arr[6] | arr[7] != 0 {
|
||||
panic!("From<U512> for U128: encountered overflow")
|
||||
}
|
||||
let mut ret = [0; 2];
|
||||
ret[0] = arr[0];
|
||||
ret[1] = arr[1];
|
||||
U128(ret)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U128> for U512 {
|
||||
fn from(value: U128) -> U512 {
|
||||
let U128(ref arr) = value;
|
||||
let mut ret = [0; 8];
|
||||
ret[0] = arr[0];
|
||||
ret[1] = arr[1];
|
||||
U512(ret)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<U128> for U256 {
|
||||
fn from(value: U128) -> U256 {
|
||||
let U128(ref arr) = value;
|
||||
let mut ret = [0; 4];
|
||||
ret[0] = arr[0];
|
||||
ret[1] = arr[1];
|
||||
U256(ret)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
Loading…
Reference in New Issue