mirror of https://github.com/status-im/evmc.git
Merge pull request #342 from ethereum/rust-bindgen
rust: support ParitalEq, Default, Hash on certain ffi types
This commit is contained in:
commit
bc551318e0
|
@ -20,6 +20,8 @@ fn gen_bindings() {
|
|||
.constified_enum("")
|
||||
// generate Rust enums for each evmc enum
|
||||
.rustified_enum("*")
|
||||
// force deriving the Hash trait on basic types (address, bytes32)
|
||||
.derive_hash(true)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
|
|
|
@ -8,3 +8,30 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
|
||||
// TODO: with bindgen's interface improving these may be moved to
|
||||
// bindgen configuration
|
||||
|
||||
impl PartialEq for evmc_address {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.bytes == other.bytes
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for evmc_bytes32 {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.bytes == other.bytes
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for evmc_address {
|
||||
fn default() -> Self {
|
||||
evmc_address { bytes: [0u8; 20] }
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for evmc_bytes32 {
|
||||
fn default() -> Self {
|
||||
evmc_bytes32 { bytes: [0u8; 32] }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue