From 888f0abce5621525af7b8bc6d41a1a570f30c920 Mon Sep 17 00:00:00 2001 From: Nick Furfaro Date: Tue, 25 Jan 2022 13:12:12 -0700 Subject: [PATCH] Implement the Eq trait for Address (#25) * Impl Ord for Address * Fix todo comment * Fix toml formatting * Add comment to use meq * Impl Eq for Address * Fix formatting * Remove todo --- src/address.sw | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/address.sw b/src/address.sw index 216e8287a77..4dce68bb425 100644 --- a/src/address.sw +++ b/src/address.sw @@ -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; } {