mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Fix a lot of Clippy warnings (#1808)
* fix a lot of clippy warnings * fix more clippy warnings * fix yet more clippy warnings * bump msrv to 1.70.0 to silence warnings * fix a lot of clippy warnings * fix more clippy warnings * fix yet more clippy warnings * fix a few more warnings * fix a clippy warning * remove a commented out line * silense too many arguments error * fix more clippy warnings * prefix underscore to unused vars/functions to fix warnings * use filter instead of map * move raw-rs-tests feature flat to module level to fix unused imports warnings * fix a couple of unused result warnings --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
@@ -827,7 +827,7 @@ impl NodeNetwork {
|
||||
}
|
||||
|
||||
/// Get the network the selected nodes are part of, which is either self or the nested network from nested_path. Used to get nodes selected in the layer panel when viewing a nested network.
|
||||
pub fn nested_network_for_selected_nodes<'a>(&self, nested_path: &Vec<NodeId>, mut selected_nodes: impl Iterator<Item = &'a NodeId>) -> Option<&Self> {
|
||||
pub fn nested_network_for_selected_nodes<'a>(&self, nested_path: &[NodeId], mut selected_nodes: impl Iterator<Item = &'a NodeId>) -> Option<&Self> {
|
||||
if selected_nodes.any(|node_id| self.nodes.contains_key(node_id) || self.exports_metadata.0 == *node_id || self.imports_metadata.0 == *node_id) {
|
||||
Some(self)
|
||||
} else {
|
||||
@@ -836,7 +836,7 @@ impl NodeNetwork {
|
||||
}
|
||||
|
||||
/// Get the mutable network the selected nodes are part of, which is either self or the nested network from nested_path. Used to modify nodes selected in the layer panel when viewing a nested network.
|
||||
pub fn nested_network_for_selected_nodes_mut<'a>(&mut self, nested_path: &Vec<NodeId>, mut selected_nodes: impl Iterator<Item = &'a NodeId>) -> Option<&mut Self> {
|
||||
pub fn nested_network_for_selected_nodes_mut<'a>(&mut self, nested_path: &[NodeId], mut selected_nodes: impl Iterator<Item = &'a NodeId>) -> Option<&mut Self> {
|
||||
if selected_nodes.any(|node_id| self.nodes.contains_key(node_id)) {
|
||||
Some(self)
|
||||
} else {
|
||||
@@ -1215,7 +1215,7 @@ impl NodeNetwork {
|
||||
|
||||
for (nested_input_index, nested_input) in nested_node.clone().inputs.iter().enumerate() {
|
||||
if let NodeInput::Network { import_index, .. } = nested_input {
|
||||
let parent_input = node.inputs.get(*import_index).expect(&format!("Import index {} should always exist", import_index));
|
||||
let parent_input = node.inputs.get(*import_index).unwrap_or_else(|| panic!("Import index {} should always exist", import_index));
|
||||
match *parent_input {
|
||||
// If the input to self is a node, connect the corresponding output of the inner network to it
|
||||
NodeInput::Node { node_id, output_index, lambda } => {
|
||||
|
||||
@@ -10,6 +10,7 @@ use graphene_core::{Color, Node, Type};
|
||||
use dyn_any::DynAny;
|
||||
pub use dyn_any::StaticType;
|
||||
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
|
||||
use std::fmt::Display;
|
||||
use std::hash::Hash;
|
||||
pub use std::sync::Arc;
|
||||
|
||||
@@ -173,17 +174,7 @@ tagged_value! {
|
||||
BooleanOperation(graphene_core::vector::misc::BooleanOperation),
|
||||
}
|
||||
|
||||
impl<'a> TaggedValue {
|
||||
pub fn to_string(&self) -> String {
|
||||
match self {
|
||||
TaggedValue::String(x) => x.to_string(),
|
||||
TaggedValue::U32(x) => x.to_string(),
|
||||
TaggedValue::U64(x) => x.to_string(),
|
||||
TaggedValue::F64(x) => x.to_string(),
|
||||
TaggedValue::Bool(x) => x.to_string(),
|
||||
_ => panic!("Cannot convert to string"),
|
||||
}
|
||||
}
|
||||
impl TaggedValue {
|
||||
pub fn to_primitive_string(&self) -> String {
|
||||
match self {
|
||||
TaggedValue::None => "()".to_string(),
|
||||
@@ -199,6 +190,19 @@ impl<'a> TaggedValue {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for TaggedValue {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
TaggedValue::String(x) => f.write_str(x),
|
||||
TaggedValue::U32(x) => f.write_fmt(format_args!("{x}")),
|
||||
TaggedValue::U64(x) => f.write_fmt(format_args!("{x}")),
|
||||
TaggedValue::F64(x) => f.write_fmt(format_args!("{x}")),
|
||||
TaggedValue::Bool(x) => f.write_fmt(format_args!("{x}")),
|
||||
_ => panic!("Cannot convert to string"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UpcastNode {
|
||||
value: TaggedValue,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user