fixed clippy warnings

This commit is contained in:
Dmitry Stepanov
2025-04-06 19:02:33 +03:00
parent 10a4dc048b
commit fbb1f5b158
13 changed files with 18 additions and 18 deletions
+1 -1
View File
@@ -695,7 +695,7 @@ impl CameraController {
self.stack.extend_from_slice(node.children());
if !node.global_visibility()
|| !filter.as_mut().map_or(true, |func| func(handle, node))
|| !filter.as_mut().is_none_or(|func| func(handle, node))
{
continue;
}
+2 -2
View File
@@ -137,7 +137,7 @@ impl PropertyDescriptor {
allowed_types,
);
if !items.is_empty() || allowed_types.map_or(true, |types| types.contains(&self.type_id)) {
if !items.is_empty() || allowed_types.is_none_or(|types| types.contains(&self.type_id)) {
let name = format!(
"{} ({})",
self.display_name,
@@ -587,7 +587,7 @@ impl Control for PropertySelectorWindow {
let enabled = selection.iter().all(|d| {
self.allowed_types
.as_ref()
.map_or(true, |types| types.contains(&d.type_id))
.is_none_or(|types| types.contains(&d.type_id))
});
ui.send_message(WidgetMessage::enabled(
+1 -1
View File
@@ -207,7 +207,7 @@ fn fetch_expanded_state(
.as_ref()
.and_then(|p| settings.scene_settings.get(*p))
.and_then(|s| s.node_infos.get(&node))
.map_or(true, |i| i.is_expanded)
.is_none_or(|i| i.is_expanded)
}
impl WorldViewer {
+1 -1
View File
@@ -436,7 +436,7 @@ impl<T: EntityId> LogicNode<T> {
LogicNode::Not(node) => !node.lhs.calculate_value(parameters, animations),
LogicNode::IsAnimationEnded(animation) => animations
.try_get(*animation)
.map_or(true, |a| a.has_ended()),
.is_none_or(|a| a.has_ended()),
}
}
}
+1 -1
View File
@@ -558,7 +558,7 @@ impl ScriptMessageDispatcher {
while let Ok(message) = self.message_receiver.try_recv() {
let receivers = self.type_groups.get(&message.payload.deref().type_id());
if receivers.map_or(true, |r| r.is_empty()) {
if receivers.is_none_or(|r| r.is_empty()) {
Log::warn(format!(
"Script message {message:?} was sent, but there's no receivers. \
Did you forgot to subscribe your script to the message?"
+1 -1
View File
@@ -235,7 +235,7 @@ impl GBuffer {
let instance_filter = |instance: &SurfaceInstanceData| {
!quality_settings.use_occlusion_culling
|| grid_cell.map_or(true, |cell| cell.is_visible(instance.node_handle))
|| grid_cell.is_none_or(|cell| cell.is_visible(instance.node_handle))
};
statistics += bundle_storage.render_to_frame_buffer(
+2 -2
View File
@@ -62,13 +62,13 @@ impl NodeVisibilityMap {
pub fn is_visible(&self, node: Handle<Node>) -> bool {
self.map
.get(&node)
.map_or(true, |vis| vis.should_be_rendered())
.is_none_or(|vis| vis.should_be_rendered())
}
pub fn needs_occlusion_query(&self, node: Handle<Node>) -> bool {
self.map
.get(&node)
.map_or(true, |vis| *vis == Visibility::Invisible)
.is_none_or(|vis| *vis == Visibility::Invisible)
}
}
+2 -2
View File
@@ -913,7 +913,7 @@ impl Graph {
let parent_enabled = nodes
.try_borrow(node.parent())
.map_or(true, |p| p.is_globally_enabled());
.is_none_or(|p| p.is_globally_enabled());
node.global_enabled.set(parent_enabled && node.is_enabled());
for &child in node.children() {
@@ -928,7 +928,7 @@ impl Graph {
let parent_visibility = nodes
.try_borrow(node.parent())
.map_or(true, |p| p.global_visibility());
.is_none_or(|p| p.global_visibility());
node.global_visibility
.set(parent_visibility && node.visibility());
+1 -1
View File
@@ -179,7 +179,7 @@ impl SoundContext {
node_overrides: Option<&FxHashSet<Handle<Node>>>,
) {
if !sound.is_globally_enabled()
|| !node_overrides.map_or(true, |f| f.contains(&sound_handle))
|| !node_overrides.is_none_or(|f| f.contains(&sound_handle))
{
self.remove_sound(sound.native.get(), &sound.name);
sound.native.set(Default::default());
+3 -3
View File
@@ -1374,7 +1374,7 @@ fn resize_f32(mut data: Vec<f32>, data_size: Vector2<u32>, new_size: Vector2<u32
if range == 0.0 {
let size: usize = (new_size.x * new_size.y) as usize;
data.clear();
data.extend(std::iter::repeat(min).take(size));
data.extend(std::iter::repeat_n(min, size));
return data;
}
@@ -1406,7 +1406,7 @@ fn create_zero_margin(mut data: Vec<f32>, data_size: Vector2<u32>) -> Vec<f32> {
let h0 = data_size.y as usize;
let h1 = h0 + 2;
let new_area = w1 * h1;
data.extend(std::iter::repeat(0.0).take(new_area - data.len()));
data.extend(std::iter::repeat_n(0.0, new_area - data.len()));
for y in (0..h0).rev() {
let i0 = y * w0;
let i1 = (y + 1) * w1;
@@ -2602,7 +2602,7 @@ impl NodeTrait for Terrain {
|| (self.frustum_culling()
&& !ctx
.frustum
.map_or(true, |f| f.is_intersects_aabb(&self.world_bounding_box())))
.is_none_or(|f| f.is_intersects_aabb(&self.world_bounding_box())))
{
return RdcControlFlow::Continue;
}
+1 -1
View File
@@ -316,7 +316,7 @@ impl QuadTreeNode {
let aabb = self.aabb(transform, height_map_size, physical_size);
if !frustum.map_or(true, |f| f.is_intersects_aabb(&aabb))
if !frustum.is_none_or(|f| f.is_intersects_aabb(&aabb))
|| !aabb.is_intersects_sphere(camera_position, radius)
{
// This node is out of range, so add nothing to `selection` and return.
+1 -1
View File
@@ -869,7 +869,7 @@ fn build_all(
#[allow(clippy::blocks_in_conditions)]
if filter
.as_mut()
.map_or(true, |f| f.0.borrow_mut().deref_mut().lock()(&path))
.is_none_or(|f| f.0.borrow_mut().deref_mut().lock()(&path))
{
let is_part_of_final_path = next.as_ref().is_some_and(|next| *next == path);
+1 -1
View File
@@ -722,7 +722,7 @@ impl FormattedText {
let mut x = line.x_offset.floor();
if let Some(mask) = *self.mask_char {
let mut prev = None;
for c in std::iter::repeat::<char>(mask).take(line.len()) {
for c in std::iter::repeat_n(mask, line.len()) {
let (glyph, advance) =
build_glyph(&mut metrics, x, y, c, prev, self.super_sampling_scale);
self.glyphs.push(glyph);