[PATCH] Add some trait derivations to instructions
Export this patch
---
primitives/src/instructions.rs | 10 +++++-----
primitives/src/registers.rs | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/primitives/src/instructions.rs b/primitives/src/instructions.rs
index cc39b55..3d08f21 100644
--- a/primitives/src/instructions.rs
+++ b/primitives/src/instructions.rs
@@ -5,7 +5,7 @@ use crate::registers::Register;
use crate::types::Word;
use crate::utils::sign_extend;
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Instruction {
// Conditional branch
BR(u16, u16),
@@ -42,7 +42,7 @@ pub enum Instruction {
}
// TODO: avoid this mode repetition
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AddMode {
Register(Register),
Immediate(u16),
@@ -57,7 +57,7 @@ impl AddMode {
}
}
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AndMode {
Register(Register),
Immediate(u16),
@@ -72,7 +72,7 @@ impl AndMode {
}
}
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum JsrMode {
Offset(u16),
Register(Register),
@@ -87,7 +87,7 @@ impl JsrMode {
}
}
-#[derive(Copy, Clone, Debug, TryFromPrimitive, IntoPrimitive)]
+#[derive(Copy, Clone, Debug, TryFromPrimitive, IntoPrimitive, PartialEq, Eq)]
#[repr(u16)]
pub enum TrapVector {
GETC = 0x20,
diff --git a/primitives/src/registers.rs b/primitives/src/registers.rs
index bf65419..ed4d442 100644
--- a/primitives/src/registers.rs
+++ b/primitives/src/registers.rs
@@ -8,7 +8,7 @@ use crate::types::{IntoUsize, Word};
pub const PC_START: Word = 0x3000;
#[repr(u16)]
-#[derive(Debug, Copy, Clone, TryFromPrimitive, IntoPrimitive)]
+#[derive(Debug, Copy, Clone, TryFromPrimitive, IntoPrimitive, PartialEq, Eq)]
pub enum Register {
/// General purpose registeristers
R0 = 0,
--
2.36.1
Thank you for the patch!