From 24c21b8a5d4e468db5f260b4fe7edc2742659e96 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Mon, 14 Oct 2024 18:57:12 -0700 Subject: [PATCH] Rust 1.82: Use `Option::is_none_or()` --- all-is-cubes-base/src/raycast/tests.rs | 3 +-- all-is-cubes-mesh/src/space_mesh.rs | 2 +- all-is-cubes-port/src/gltf.rs | 4 ++-- all-is-cubes/src/behavior.rs | 2 +- all-is-cubes/src/space/light/queue.rs | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/all-is-cubes-base/src/raycast/tests.rs b/all-is-cubes-base/src/raycast/tests.rs index c0a194cfc..51d66a593 100644 --- a/all-is-cubes-base/src/raycast/tests.rs +++ b/all-is-cubes-base/src/raycast/tests.rs @@ -27,8 +27,7 @@ impl TestStep { fn matches(self, step: &RaycastStep) -> bool { self.cube == step.cube_ahead() && self.face == step.face() - && self.t_distance.map_or(true, |td| step.t_distance() == td) - && self.t_distance.map_or(true, |td| step.t_distance() == td) + && self.t_distance.is_none_or(|td| step.t_distance() == td) } } diff --git a/all-is-cubes-mesh/src/space_mesh.rs b/all-is-cubes-mesh/src/space_mesh.rs index 5cbb2abc1..d618e13ad 100644 --- a/all-is-cubes-mesh/src/space_mesh.rs +++ b/all-is-cubes-mesh/src/space_mesh.rs @@ -258,7 +258,7 @@ impl SpaceMesh { if let Some(adj_block_index) = space_data_source(adjacent_cube) { if block_meshes .get_block_mesh(adj_block_index, adjacent_cube, false) - .map_or(false, |bm| bm.face_vertices[face.opposite()].fully_opaque) + .is_some_and(|bm| bm.face_vertices[face.opposite()].fully_opaque) { // Don't draw obscured faces, but do record that we depended on them. bitset_set_and_get( diff --git a/all-is-cubes-port/src/gltf.rs b/all-is-cubes-port/src/gltf.rs index 43bb50436..8f359b5e3 100644 --- a/all-is-cubes-port/src/gltf.rs +++ b/all-is-cubes-port/src/gltf.rs @@ -251,7 +251,7 @@ impl GltfWriter { for (frame_number, state) in self.frame_states.iter().enumerate() { for &instance in &state.visible_mesh_instances { let timeline = timelines.entry(instance).or_default(); - if !timeline.last().map_or(true, |&(_, vis)| vis) { + if !timeline.last().is_none_or(|&(_, vis)| vis) { // Node needs to be made visible. timeline.push((frame_number, true)); } @@ -267,7 +267,7 @@ impl GltfWriter { match timelines.entry(instance) { Entry::Occupied(mut e) => { let timeline = e.get_mut(); - if timeline.last().map_or(true, |&(_, vis)| vis) { + if timeline.last().is_none_or(|&(_, vis)| vis) { // Node needs to be made invisible. timeline.push((frame_number, false)); } diff --git a/all-is-cubes/src/behavior.rs b/all-is-cubes/src/behavior.rs index 8056fd16a..9f5e77a67 100644 --- a/all-is-cubes/src/behavior.rs +++ b/all-is-cubes/src/behavior.rs @@ -191,7 +191,7 @@ impl BehaviorSet { } }, ) - .filter(move |qi| type_filter.map_or(true, |t| (*qi.behavior).type_id() == t)) + .filter(move |qi| type_filter.is_none_or(|t| (*qi.behavior).type_id() == t)) } pub(crate) fn step( diff --git a/all-is-cubes/src/space/light/queue.rs b/all-is-cubes/src/space/light/queue.rs index 940479f82..c1906ca23 100644 --- a/all-is-cubes/src/space/light/queue.rs +++ b/all-is-cubes/src/space/light/queue.rs @@ -213,7 +213,7 @@ impl LightUpdateQueue { #[inline] pub fn pop(&mut self) -> Option { if let Some(sweep) = &mut self.sweep { - if peek_priority(&self.queue).map_or(true, |p| self.sweep_priority > p) { + if peek_priority(&self.queue).is_none_or(|p| self.sweep_priority > p) { if let Some(cube) = sweep.next() { return Some(LightUpdateRequest { cube,