summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Harry Cutts <hcutts@google.com> 2025-01-31 16:47:55 +0000
committer Harry Cutts <hcutts@google.com> 2025-02-07 15:05:00 +0000
commitc932b0717a30853f5ce2ad20c43f7a42d690ad32 (patch)
tree9e7c6ab12bd97db73c33537e87014363f993f55f
parent21a46533f21facb9fa8636ac8f917294348a760e (diff)
InputVerifier: use `let ... else` when converting flags and buttons
Bug: 245989146 Test: enable the verifier, check everything works as usual Flag: EXEMPT refactor Change-Id: I3debc83da82168f9c5a7e3eccb2f8dc6edbabaed
-rw-r--r--libs/input/rust/lib.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/libs/input/rust/lib.rs b/libs/input/rust/lib.rs
index 3a347c4c4a..8b8a39ecca 100644
--- a/libs/input/rust/lib.rs
+++ b/libs/input/rust/lib.rs
@@ -133,36 +133,33 @@ fn process_movement(
flags: u32,
button_state: u32,
) -> String {
- let motion_flags = MotionFlags::from_bits(flags);
- if motion_flags.is_none() {
+ let Some(motion_flags) = MotionFlags::from_bits(flags) else {
panic!(
"The conversion of flags 0x{:08x} failed, please check if some flags have not been \
added to MotionFlags.",
flags
);
- }
- let motion_action_button = MotionButton::from_bits(action_button);
- if motion_action_button.is_none() {
+ };
+ let Some(motion_action_button) = MotionButton::from_bits(action_button) else {
panic!(
"The conversion of action button 0x{action_button:08x} failed, please check if some \
buttons need to be added to MotionButton."
);
- }
- let motion_button_state = MotionButton::from_bits(button_state);
- if motion_button_state.is_none() {
+ };
+ let Some(motion_button_state) = MotionButton::from_bits(button_state) else {
panic!(
"The conversion of button state 0x{button_state:08x} failed, please check if some \
buttons need to be added to MotionButton."
);
- }
+ };
let result = verifier.process_movement(NotifyMotionArgs {
device_id: DeviceId(device_id),
source: Source::from_bits(source).unwrap(),
action,
- action_button: motion_action_button.unwrap(),
+ action_button: motion_action_button,
pointer_properties,
- flags: motion_flags.unwrap(),
- button_state: motion_button_state.unwrap(),
+ flags: motion_flags,
+ button_state: motion_button_state,
});
match result {
Ok(()) => "".to_string(),