From f2f4dcd0f1494f21537b84370c7f630720e4494a Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 18 Jan 2020 14:37:30 -0800 Subject: use yaxpeax-arch --- src/lib.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index fa12750..e83a8b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,15 +42,17 @@ pub struct Instruction { opcode: Opcode, } -impl Instruction { - fn blank() -> Self { +impl Default for Instruction { + fn default() -> Self { Instruction { word: 0, operands: [OperandSpec::Nothing, OperandSpec::Nothing, OperandSpec::Nothing], opcode: Opcode::J, } } +} +impl Instruction { fn operand(&self, op: &OperandSpec) -> Option { match op { OperandSpec::Nothing => None, @@ -274,12 +276,6 @@ pub struct MipsDecoder {} impl Decoder for MipsDecoder { type Error = DecodeError; - fn decode>(&self, bytes: T) -> Result { - let mut blank = Instruction::blank(); - self.decode_into(&mut blank, bytes) - .map(|_: ()| blank) - } - fn decode_into>(&self, instruction: &mut Instruction, bytes: T) -> Result<(), Self::Error> { let mut bytes_iter = bytes.into_iter(); let word: Vec = bytes_iter.by_ref().take(4).collect(); -- cgit v1.1