Skip to content

Commit

Permalink
Implement the Eq trait for Address (FuelLabs#25)
Browse files Browse the repository at this point in the history
* Impl Ord for Address

* Fix todo comment

* Fix toml formatting

* Add comment to use meq

* Impl Eq for Address

* Fix formatting

* Remove todo
  • Loading branch information
nfurfaro authored Jan 25, 2022
1 parent 193114a commit 888f0ab
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/address.sw
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ pub struct Address {
value: b256,
}

// @todo make this generic when possible
impl core::ops::Eq for Address {
fn eq(self, other: Self) -> bool {
// An `Address` in Sway is 32 bytes
asm(r1: self, r2: other, result, bytes_to_compare: 32) {
meq result r1 r2 bytes_to_compare;
result: bool
}
}
}

pub trait From {
fn from(b: b256) -> Self;
} {
Expand Down

0 comments on commit 888f0ab

Please sign in to comment.