summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 67272b0..68f0819 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -22,6 +22,25 @@ pub struct Instruction {
length: u8,
}
+impl PartialEq for Instruction {
+ fn eq(&self, other: &Self) -> bool {
+ let Instruction {
+ opcode: left_opcode,
+ operands: _, // we won't use this `operands`, but `.operands()` to not use stale extra operands
+ length: left_length,
+ } = self;
+ let Instruction {
+ opcode: right_opcode,
+ operands: _, // we won't use this `operands`, but `.operands()` to not use stale extra operands
+ length: right_length,
+ } = other;
+
+ left_opcode == right_opcode &&
+ left_length == right_length &&
+ self.operands() == other.operands()
+ }
+}
+
impl Instruction {
pub fn opcode(&self) -> Opcode {
self.opcode