Skip to content

Commit

Permalink
Clean up a let-else that is possible in Rust 1.68
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Nov 20, 2023
1 parent e14d2c1 commit a84722f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
12 changes: 5 additions & 7 deletions android-activity/src/game_activity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,18 +768,16 @@ impl<'a> From<Arc<InputReceiver>> for InputIteratorInner<'a> {
let buffered = unsafe {
let app_ptr = receiver.native_app.as_ptr();
let input_buffer = ffi::android_app_swap_input_buffers(app_ptr);
if input_buffer.is_null() {
None
} else {
let buffer = InputBuffer::from_ptr(NonNull::new_unchecked(input_buffer));
NonNull::new(input_buffer).map(|input_buffer| {
let buffer = InputBuffer::from_ptr(input_buffer);
let keys_iter = KeyEventsLendingIterator::new(&buffer);
let motion_iter = MotionEventsLendingIterator::new(&buffer);
Some(BufferedEvents::<'a> {
BufferedEvents::<'a> {
buffer,
keys_iter,
motion_iter,
})
}
}
})
};

let native_app = receiver.native_app.clone();
Expand Down
2 changes: 2 additions & 0 deletions android-activity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
//! [`GameActivity`]: https://developer.android.com/games/agdk/integrate-game-activity
//! [Looper]: https://developer.android.com/reference/android/os/Looper

#![deny(clippy::manual_let_else)]

use std::hash::Hash;
use std::sync::Arc;
use std::sync::RwLock;
Expand Down
6 changes: 1 addition & 5 deletions android-activity/src/native_activity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,7 @@ impl<'a> InputIteratorInner<'a> {
where
F: FnOnce(&input::InputEvent) -> InputStatus,
{
// XXX: would use `let Some(queue) = &self.receiver.queue else { return
// false; }` but we're stuck supporting Rust 1.64 for Winit currently
let queue = if let Some(queue) = &self.receiver.queue {
queue
} else {
let Some(queue) = &self.receiver.queue else {
log::trace!("no queue available for events");
return false;
};
Expand Down

0 comments on commit a84722f

Please sign in to comment.