Skip to content

Commit 5b87543

Browse files
committed
Apply clippy lints
1 parent 1542d6f commit 5b87543

File tree

13 files changed

+45
-64
lines changed

13 files changed

+45
-64
lines changed

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ impl DocumentMessageHandler {
16551655
path.pop();
16561656
}
16571657
}
1658-
structure_section.push(space | 1 << 63);
1658+
structure_section.push(space | (1 << 63));
16591659
}
16601660

16611661
/// Serializes the layer structure into a condensed 1D structure.

editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,16 +2114,11 @@ impl NodeGraphMessageHandler {
21142114
wire_end: InputConnector::Export(i),
21152115
dashed,
21162116
});
2117-
} else {
2118-
match *export {
2119-
NodeInput::Network { import_index, .. } => wires.push(FrontendNodeWire {
2120-
wire_start: OutputConnector::Import(import_index),
2121-
wire_end: InputConnector::Export(i),
2122-
dashed,
2123-
}),
2124-
_ => {}
2125-
}
2126-
}
2117+
} else if let NodeInput::Network { import_index, .. } = *export { wires.push(FrontendNodeWire {
2118+
wire_start: OutputConnector::Import(import_index),
2119+
wire_end: InputConnector::Export(i),
2120+
dashed,
2121+
}) }
21272122
}
21282123
}
21292124
wires

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
22262226
&document_node.inputs[backup_color_index].as_value(),
22272227
&document_node.inputs[backup_gradient_index].as_value(),
22282228
) {
2229-
(&Some(&TaggedValue::Fill(ref fill)), &Some(&TaggedValue::OptionalColor(backup_color)), &Some(&TaggedValue::Gradient(ref backup_gradient))) => (fill, backup_color, backup_gradient),
2229+
(&Some(TaggedValue::Fill(fill)), &Some(&TaggedValue::OptionalColor(backup_color)), &Some(TaggedValue::Gradient(backup_gradient))) => (fill, backup_color, backup_gradient),
22302230
_ => {
22312231
return vec![LayoutGroup::Row { widgets: widgets_first_row }];
22322232
}

editor/src/messages/portfolio/document/utility_types/network_interface.rs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl NodeNetworkInterface {
366366

367367
// If a chain node does not have a selected downstream layer, then set the position to absolute
368368
let downstream_layer = self.downstream_layer(node_id, network_path);
369-
if downstream_layer.map_or(true, |downstream_layer| new_ids.keys().all(|key| *key != downstream_layer.to_node())) {
369+
if downstream_layer.is_none_or(|downstream_layer| new_ids.keys().all(|key| *key != downstream_layer.to_node())) {
370370
let Some(position) = self.position(node_id, network_path) else {
371371
log::error!("Could not get position in create_node_template");
372372
return None;
@@ -4688,16 +4688,13 @@ impl NodeNetworkInterface {
46884688
node_metadata.position = NodePosition::Absolute(position);
46894689
self.transaction_modified();
46904690
}
4691-
_ => match &mut node_metadata.persistent_metadata.node_type_metadata {
4692-
NodeTypePersistentMetadata::Layer(layer_metadata) => {
4693-
if layer_metadata.position == LayerPosition::Absolute(position) {
4694-
return;
4695-
}
4696-
layer_metadata.position = LayerPosition::Absolute(position);
4697-
self.transaction_modified();
4698-
}
4699-
_ => {}
4700-
},
4691+
_ => if let NodeTypePersistentMetadata::Layer(layer_metadata) = &mut node_metadata.persistent_metadata.node_type_metadata {
4692+
if layer_metadata.position == LayerPosition::Absolute(position) {
4693+
return;
4694+
}
4695+
layer_metadata.position = LayerPosition::Absolute(position);
4696+
self.transaction_modified();
4697+
},
47014698
}
47024699
}
47034700

@@ -5334,21 +5331,18 @@ impl NodeNetworkInterface {
53345331
self.unload_upstream_node_click_targets(vec![*node_id], network_path);
53355332
}
53365333
_ => {
5337-
match &mut node_metadata.persistent_metadata.node_type_metadata {
5338-
NodeTypePersistentMetadata::Node(node_metadata) => {
5339-
if let NodePosition::Absolute(node_metadata) = &mut node_metadata.position {
5340-
*node_metadata += shift;
5341-
self.transaction_modified();
5342-
// Unload click targets for all upstream nodes, since they may have been derived from the node that was shifted
5343-
self.unload_upstream_node_click_targets(vec![*node_id], network_path);
5344-
self.try_set_node_to_chain(node_id, network_path);
5345-
} else if let NodePosition::Chain = node_metadata.position {
5346-
self.set_upstream_chain_to_absolute(node_id, network_path);
5347-
self.shift_node(node_id, shift, network_path);
5348-
}
5349-
}
5350-
_ => {}
5351-
}
5334+
if let NodeTypePersistentMetadata::Node(node_metadata) = &mut node_metadata.persistent_metadata.node_type_metadata {
5335+
if let NodePosition::Absolute(node_metadata) = &mut node_metadata.position {
5336+
*node_metadata += shift;
5337+
self.transaction_modified();
5338+
// Unload click targets for all upstream nodes, since they may have been derived from the node that was shifted
5339+
self.unload_upstream_node_click_targets(vec![*node_id], network_path);
5340+
self.try_set_node_to_chain(node_id, network_path);
5341+
} else if let NodePosition::Chain = node_metadata.position {
5342+
self.set_upstream_chain_to_absolute(node_id, network_path);
5343+
self.shift_node(node_id, shift, network_path);
5344+
}
5345+
}
53525346
}
53535347
}
53545348
// Unload click targets for all upstream nodes, since they may have been derived from the node that was shifted

editor/src/messages/tool/common_functionality/shape_editor.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,15 +1075,10 @@ impl ShapeState {
10751075
responses.add(GraphOperationMessage::Vector { layer, modification_type });
10761076
}
10771077
}
1078-
} else {
1079-
match point.get_handle_pair(&vector_data) {
1080-
Some(handles) => {
1081-
let modification_type = VectorModificationType::SetG1Continuous { handles, enabled: false };
1082-
responses.add(GraphOperationMessage::Vector { layer, modification_type });
1083-
}
1084-
_ => {}
1085-
}
1086-
}
1078+
} else if let Some(handles) = point.get_handle_pair(&vector_data) {
1079+
let modification_type = VectorModificationType::SetG1Continuous { handles, enabled: false };
1080+
responses.add(GraphOperationMessage::Vector { layer, modification_type });
1081+
}
10871082
}
10881083
}
10891084
}

editor/src/messages/tool/common_functionality/snapping/alignment_snapper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl AlignmentSnapper {
8989
if let Some(point_on_x) = point_on_x {
9090
let distance_to_snapped = point.document_point.distance(point_on_x);
9191
let distance_to_align_target = point_on_x.distance(target_position);
92-
if distance_to_snapped < tolerance && snap_x.as_ref().map_or(true, |point| distance_to_align_target < point.distance_to_align_target) {
92+
if distance_to_snapped < tolerance && snap_x.as_ref().is_none_or(|point| distance_to_align_target < point.distance_to_align_target) {
9393
snap_x = Some(SnappedPoint {
9494
snapped_point_document: point_on_x,
9595
source: point.source, // TODO(0Hypercube): map source
@@ -108,7 +108,7 @@ impl AlignmentSnapper {
108108
if let Some(point_on_y) = point_on_y {
109109
let distance_to_snapped = point.document_point.distance(point_on_y);
110110
let distance_to_align_target = point_on_y.distance(target_position);
111-
if distance_to_snapped < tolerance && snap_y.as_ref().map_or(true, |point| distance_to_align_target < point.distance_to_align_target) {
111+
if distance_to_snapped < tolerance && snap_y.as_ref().is_none_or(|point| distance_to_align_target < point.distance_to_align_target) {
112112
snap_y = Some(SnappedPoint {
113113
snapped_point_document: point_on_y,
114114
source: point.source, // TODO(0Hypercube): map source

editor/src/messages/tool/tool_messages/freehand_tool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl Fsm for FreehandToolFsmState {
311311
}
312312

313313
fn extend_path_with_next_segment(tool_data: &mut FreehandToolData, position: DVec2, extend: bool, responses: &mut VecDeque<Message>) {
314-
if !tool_data.end_point.map_or(true, |(last_pos, _)| position != last_pos) || !position.is_finite() {
314+
if !tool_data.end_point.is_none_or(|(last_pos, _)| position != last_pos) || !position.is_finite() {
315315
return;
316316
}
317317

editor/src/messages/tool/tool_messages/spline_tool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl Fsm for SplineToolFsmState {
364364
return SplineToolFsmState::Ready;
365365
};
366366
tool_data.next_point = tool_data.snapped_point(document, input).snapped_point_document;
367-
if tool_data.points.last().map_or(true, |last_pos| last_pos.1.distance(tool_data.next_point) > DRAG_THRESHOLD) {
367+
if tool_data.points.last().is_none_or(|last_pos| last_pos.1.distance(tool_data.next_point) > DRAG_THRESHOLD) {
368368
let preview_point = tool_data.preview_point;
369369
extend_spline(tool_data, false, responses);
370370
tool_data.preview_point = preview_point;

editor/src/node_graph_executor.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,9 @@ impl NodeRuntime {
299299
Some(record) => {
300300
self.vector_modify.insert(parent_network_node_id, record.output.one_instance().instance.clone());
301301
}
302-
_ => match introspected_data.downcast_ref::<IORecord<(), VectorDataTable>>() {
303-
Some(record) => {
304-
self.vector_modify.insert(parent_network_node_id, record.output.one_instance().instance.clone());
305-
}
306-
_ => {}
307-
},
302+
_ => if let Some(record) = introspected_data.downcast_ref::<IORecord<(), VectorDataTable>>() {
303+
self.vector_modify.insert(parent_network_node_id, record.output.one_instance().instance.clone());
304+
},
308305
},
309306
},
310307
},

libraries/bezier-rs/src/subpath/solvers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -954,19 +954,19 @@ mod tests {
954954

955955
let curve = Bezier::from_quadratic_dvec2(DVec2::new(189., 289.), DVec2::new(9., 286.), DVec2::new(45., 410.));
956956
let curve_intersecting = Subpath::<EmptyId>::from_bezier(&curve);
957-
assert_eq!(curve_intersecting.is_inside_subpath(&boundary_polygon, None, None), false);
957+
assert!(!curve_intersecting.is_inside_subpath(&boundary_polygon, None, None));
958958

959959
let curve = Bezier::from_quadratic_dvec2(DVec2::new(115., 37.), DVec2::new(51.4, 91.8), DVec2::new(76.5, 242.));
960960
let curve_outside = Subpath::<EmptyId>::from_bezier(&curve);
961-
assert_eq!(curve_outside.is_inside_subpath(&boundary_polygon, None, None), false);
961+
assert!(!curve_outside.is_inside_subpath(&boundary_polygon, None, None));
962962

963963
let curve = Bezier::from_cubic_dvec2(DVec2::new(210.1, 133.5), DVec2::new(150.2, 436.9), DVec2::new(436., 285.), DVec2::new(247.6, 240.7));
964964
let curve_inside = Subpath::<EmptyId>::from_bezier(&curve);
965-
assert_eq!(curve_inside.is_inside_subpath(&boundary_polygon, None, None), true);
965+
assert!(curve_inside.is_inside_subpath(&boundary_polygon, None, None));
966966

967967
let line = Bezier::from_linear_dvec2(DVec2::new(101., 101.5), DVec2::new(150.2, 499.));
968968
let line_inside = Subpath::<EmptyId>::from_bezier(&line);
969-
assert_eq!(line_inside.is_inside_subpath(&boundary_polygon, None, None), true);
969+
assert!(line_inside.is_inside_subpath(&boundary_polygon, None, None));
970970
}
971971

972972
#[test]

0 commit comments

Comments
 (0)