Fix [u8; $n_words] conversion
Remove unneeded ref conversion impl Better test value
This commit is contained in:
parent
72e84868e8
commit
283b13f114
|
@ -816,17 +816,13 @@ macro_rules! construct_uint {
|
|||
|
||||
impl From<[u8; $n_words * 8]> for $name {
|
||||
fn from(bytes: [u8; $n_words * 8]) -> Self {
|
||||
let mut bytes = bytes;
|
||||
bytes[..].reverse();
|
||||
let bytes : [u64; $n_words] = unsafe { ::core::mem::transmute(bytes)};
|
||||
$name(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a [u8; $n_words * 8]> for $name {
|
||||
fn from(bytes: &[u8; $n_words * 8]) -> Self {
|
||||
bytes[..].into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for $name {
|
||||
fn default() -> Self {
|
||||
$name::zero()
|
||||
|
|
|
@ -1017,14 +1017,14 @@ fn test_u256_from_fixed_array() {
|
|||
let ary = [
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 123
|
||||
0, 0, 0, 0, 0, 0, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 123,
|
||||
];
|
||||
let num : U256 = ary.into();
|
||||
assert_eq!( num, U256::from(123) );
|
||||
assert_eq!( num, U256::from(std::u64::MAX) + 1 + 123);
|
||||
|
||||
let a_ref : &U256 = &ary.into();
|
||||
assert_eq!( a_ref, &U256::from(123) );
|
||||
assert_eq!( a_ref, &(U256::from(std::u64::MAX) + 1 + 123));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in New Issue