Broken casting.
This commit is contained in:
parent
5fd5c461b3
commit
46810e961c
34
src/hash.rs
34
src/hash.rs
@ -412,8 +412,18 @@ macro_rules! impl_hash {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a U256> for H256 {
|
impl From<U256> for H256 {
|
||||||
fn from(value: &'a U256) -> H256 {
|
fn from(value: U256) -> H256 {
|
||||||
|
unsafe {
|
||||||
|
let mut ret: H256 = ::std::mem::uninitialized();
|
||||||
|
value.to_bytes(&mut ret);
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'_> From<&'_ U256> for H256 {
|
||||||
|
fn from(value: &'_ U256) -> H256 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut ret: H256 = ::std::mem::uninitialized();
|
let mut ret: H256 = ::std::mem::uninitialized();
|
||||||
value.to_bytes(&mut ret);
|
value.to_bytes(&mut ret);
|
||||||
@ -432,6 +442,16 @@ impl From<H256> for Address {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'_> From<&'_ H256> for Address {
|
||||||
|
fn from(value: &'_ H256) -> Address {
|
||||||
|
unsafe {
|
||||||
|
let mut ret: Address = ::std::mem::uninitialized();
|
||||||
|
::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20);
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<Address> for H256 {
|
impl From<Address> for H256 {
|
||||||
fn from(value: Address) -> H256 {
|
fn from(value: Address) -> H256 {
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -442,6 +462,16 @@ impl From<Address> for H256 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'_> From<&'_ Address> for H256 {
|
||||||
|
fn from(value: &'_ Address) -> H256 {
|
||||||
|
unsafe {
|
||||||
|
let mut ret = H256::new();
|
||||||
|
::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20);
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn h256_from_hex(s: &str) -> H256 {
|
pub fn h256_from_hex(s: &str) -> H256 {
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
H256::from_str(s).unwrap()
|
H256::from_str(s).unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user