Skip to content

Commit

Permalink
Rust 1.82: Use Option::is_none_or()
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Oct 17, 2024
1 parent c0f759b commit 5f4be6f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions all-is-cubes-base/src/raycast/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-mesh/src/space_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<M: MeshTypes> SpaceMesh<M> {
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(
Expand Down
4 changes: 2 additions & 2 deletions all-is-cubes-port/src/gltf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/behavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<H: Host> BehaviorSet<H> {
}
},
)
.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(
Expand Down
10 changes: 4 additions & 6 deletions all-is-cubes/src/block/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,10 @@ impl BlockAttributes {

inventory.rotationally_symmetric()
&& rotation_rule.rotationally_symmetric()
&& !tick_action
.as_ref()
.is_some_and(|a| !a.rotationally_symmetric())
&& !activation_action
.as_ref()
.is_some_and(|a| !a.rotationally_symmetric())
&& tick_action
.as_ref().is_none_or(|a| a.rotationally_symmetric())
&& activation_action
.as_ref().is_none_or(|a| a.rotationally_symmetric())
}

pub(crate) fn rotate(self, rotation: GridRotation) -> BlockAttributes {
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/space/light/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl LightUpdateQueue {
#[inline]
pub fn pop(&mut self) -> Option<LightUpdateRequest> {
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,
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes/src/space/light/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl LightStorage {
let Some(region) = region.intersection_cubes(self.contents.bounds()) else {
return;
};
if !region.volume().is_some_and(|v| v <= 400) {
if region.volume().is_none_or(|v| v > 400) {
self.light_update_queue.sweep(region, priority);
} else {
for cube in region.interior_iter() {
Expand Down

0 comments on commit 5f4be6f

Please sign in to comment.