Skip to content

Commit 385886d

Browse files
committed
Apply clippy lints
1 parent 6ddd17c commit 385886d

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
@@ -1662,7 +1662,7 @@ impl DocumentMessageHandler {
16621662
path.pop();
16631663
}
16641664
}
1665-
structure_section.push(space | 1 << 63);
1665+
structure_section.push(space | (1 << 63));
16661666
}
16671667

16681668
/// 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
@@ -2111,16 +2111,11 @@ impl NodeGraphMessageHandler {
21112111
wire_end: InputConnector::Export(i),
21122112
dashed,
21132113
});
2114-
} else {
2115-
match *export {
2116-
NodeInput::Network { import_index, .. } => wires.push(FrontendNodeWire {
2117-
wire_start: OutputConnector::Import(import_index),
2118-
wire_end: InputConnector::Export(i),
2119-
dashed,
2120-
}),
2121-
_ => {}
2122-
}
2123-
}
2114+
} else if let NodeInput::Network { import_index, .. } = *export { wires.push(FrontendNodeWire {
2115+
wire_start: OutputConnector::Import(import_index),
2116+
wire_end: InputConnector::Export(i),
2117+
dashed,
2118+
}) }
21242119
}
21252120
}
21262121
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
@@ -2223,7 +2223,7 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
22232223
&document_node.inputs[backup_color_index].as_value(),
22242224
&document_node.inputs[backup_gradient_index].as_value(),
22252225
) {
2226-
(&Some(&TaggedValue::Fill(ref fill)), &Some(&TaggedValue::OptionalColor(backup_color)), &Some(&TaggedValue::Gradient(ref backup_gradient))) => (fill, backup_color, backup_gradient),
2226+
(&Some(TaggedValue::Fill(fill)), &Some(&TaggedValue::OptionalColor(backup_color)), &Some(TaggedValue::Gradient(backup_gradient))) => (fill, backup_color, backup_gradient),
22272227
_ => {
22282228
return vec![LayoutGroup::Row { widgets: widgets_first_row }];
22292229
}

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

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

351351
// If a chain node does not have a selected downstream layer, then set the position to absolute
352352
let downstream_layer = self.downstream_layer(node_id, network_path);
353-
if downstream_layer.map_or(true, |downstream_layer| new_ids.keys().all(|key| *key != downstream_layer.to_node())) {
353+
if downstream_layer.is_none_or(|downstream_layer| new_ids.keys().all(|key| *key != downstream_layer.to_node())) {
354354
let Some(position) = self.position(node_id, network_path) else {
355355
log::error!("Could not get position in create_node_template");
356356
return None;
@@ -4660,16 +4660,13 @@ impl NodeNetworkInterface {
46604660
node_metadata.position = NodePosition::Absolute(position);
46614661
self.transaction_modified();
46624662
}
4663-
_ => match &mut node_metadata.persistent_metadata.node_type_metadata {
4664-
NodeTypePersistentMetadata::Layer(layer_metadata) => {
4665-
if layer_metadata.position == LayerPosition::Absolute(position) {
4666-
return;
4667-
}
4668-
layer_metadata.position = LayerPosition::Absolute(position);
4669-
self.transaction_modified();
4670-
}
4671-
_ => {}
4672-
},
4663+
_ => if let NodeTypePersistentMetadata::Layer(layer_metadata) = &mut node_metadata.persistent_metadata.node_type_metadata {
4664+
if layer_metadata.position == LayerPosition::Absolute(position) {
4665+
return;
4666+
}
4667+
layer_metadata.position = LayerPosition::Absolute(position);
4668+
self.transaction_modified();
4669+
},
46734670
}
46744671
}
46754672

@@ -5299,21 +5296,18 @@ impl NodeNetworkInterface {
52995296
self.unload_upstream_node_click_targets(vec![*node_id], network_path);
53005297
}
53015298
_ => {
5302-
match &mut node_metadata.persistent_metadata.node_type_metadata {
5303-
NodeTypePersistentMetadata::Node(node_metadata) => {
5304-
if let NodePosition::Absolute(node_metadata) = &mut node_metadata.position {
5305-
*node_metadata += shift;
5306-
self.transaction_modified();
5307-
// Unload click targets for all upstream nodes, since they may have been derived from the node that was shifted
5308-
self.unload_upstream_node_click_targets(vec![*node_id], network_path);
5309-
self.try_set_node_to_chain(node_id, network_path);
5310-
} else if let NodePosition::Chain = node_metadata.position {
5311-
self.set_upstream_chain_to_absolute(node_id, network_path);
5312-
self.shift_node(node_id, shift, network_path);
5313-
}
5314-
}
5315-
_ => {}
5316-
}
5299+
if let NodeTypePersistentMetadata::Node(node_metadata) = &mut node_metadata.persistent_metadata.node_type_metadata {
5300+
if let NodePosition::Absolute(node_metadata) = &mut node_metadata.position {
5301+
*node_metadata += shift;
5302+
self.transaction_modified();
5303+
// Unload click targets for all upstream nodes, since they may have been derived from the node that was shifted
5304+
self.unload_upstream_node_click_targets(vec![*node_id], network_path);
5305+
self.try_set_node_to_chain(node_id, network_path);
5306+
} else if let NodePosition::Chain = node_metadata.position {
5307+
self.set_upstream_chain_to_absolute(node_id, network_path);
5308+
self.shift_node(node_id, shift, network_path);
5309+
}
5310+
}
53175311
}
53185312
}
53195313
// 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
@@ -1069,15 +1069,10 @@ impl ShapeState {
10691069
responses.add(GraphOperationMessage::Vector { layer, modification_type });
10701070
}
10711071
}
1072-
} else {
1073-
match point.get_handle_pair(&vector_data) {
1074-
Some(handles) => {
1075-
let modification_type = VectorModificationType::SetG1Continuous { handles, enabled: false };
1076-
responses.add(GraphOperationMessage::Vector { layer, modification_type });
1077-
}
1078-
_ => {}
1079-
}
1080-
}
1072+
} else if let Some(handles) = point.get_handle_pair(&vector_data) {
1073+
let modification_type = VectorModificationType::SetG1Continuous { handles, enabled: false };
1074+
responses.add(GraphOperationMessage::Vector { layer, modification_type });
1075+
}
10811076
}
10821077
}
10831078
}

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)