Skip to content

Commit

Permalink
hypervisor: emulator: use matches!
Browse files Browse the repository at this point in the history
No functional change. Just make the code a bit nicer to read.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
  • Loading branch information
liuw authored and Sebastien Boeuf committed Jun 23, 2022
1 parent 92f559f commit 2f51452
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions hypervisor/src/arch/x86/emulator/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ fn get_op<T: CpuStateManager>(
)));
}

match op_size {
1 | 2 | 4 | 8 => {}
_ => {
return Err(PlatformError::InvalidOperand(anyhow!(
"Invalid operand size {:?}",
op_size
)))
}
if !matches!(op_size, 1 | 2 | 4 | 8) {
return Err(PlatformError::InvalidOperand(anyhow!(
"Invalid operand size {:?}",
op_size
)));
}

let value = match insn
Expand Down Expand Up @@ -81,14 +78,11 @@ fn set_op<T: CpuStateManager>(
)));
}

match op_size {
1 | 2 | 4 | 8 => {}
_ => {
return Err(PlatformError::InvalidOperand(anyhow!(
"Invalid operand size {:?}",
op_size
)))
}
if !matches!(op_size, 1 | 2 | 4 | 8) {
return Err(PlatformError::InvalidOperand(anyhow!(
"Invalid operand size {:?}",
op_size
)));
}

match insn
Expand Down

0 comments on commit 2f51452

Please sign in to comment.