mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 01:58:12 +08:00
Fix import being lost when running 'cargo fix' due to feature flag
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
use crate::document::value::TaggedValue;
|
|
||||||
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
|
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
|
||||||
use graphene_core::{NodeIdentifier, Type};
|
use graphene_core::{NodeIdentifier, Type};
|
||||||
|
|
||||||
@@ -126,7 +125,7 @@ impl DocumentNode {
|
|||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum NodeInput {
|
pub enum NodeInput {
|
||||||
Node { node_id: NodeId, output_index: usize, lambda: bool },
|
Node { node_id: NodeId, output_index: usize, lambda: bool },
|
||||||
Value { tagged_value: value::TaggedValue, exposed: bool },
|
Value { tagged_value: crate::document::value::TaggedValue, exposed: bool },
|
||||||
Network(Type),
|
Network(Type),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +136,7 @@ impl NodeInput {
|
|||||||
pub const fn lambda(node_id: NodeId, output_index: usize) -> Self {
|
pub const fn lambda(node_id: NodeId, output_index: usize) -> Self {
|
||||||
Self::Node { node_id, output_index, lambda: true }
|
Self::Node { node_id, output_index, lambda: true }
|
||||||
}
|
}
|
||||||
pub const fn value(tagged_value: value::TaggedValue, exposed: bool) -> Self {
|
pub const fn value(tagged_value: crate::document::value::TaggedValue, exposed: bool) -> Self {
|
||||||
Self::Value { tagged_value, exposed }
|
Self::Value { tagged_value, exposed }
|
||||||
}
|
}
|
||||||
fn map_ids(&mut self, f: impl Fn(NodeId) -> NodeId) {
|
fn map_ids(&mut self, f: impl Fn(NodeId) -> NodeId) {
|
||||||
@@ -632,7 +631,7 @@ mod test {
|
|||||||
inputs: vec![
|
inputs: vec![
|
||||||
NodeInput::Network(concrete!(u32)),
|
NodeInput::Network(concrete!(u32)),
|
||||||
NodeInput::Value {
|
NodeInput::Value {
|
||||||
tagged_value: value::TaggedValue::U32(2),
|
tagged_value: crate::document::value::TaggedValue::U32(2),
|
||||||
exposed: false,
|
exposed: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -698,7 +697,7 @@ mod test {
|
|||||||
construction_args: ConstructionArgs::Nodes(vec![]),
|
construction_args: ConstructionArgs::Nodes(vec![]),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(14, ProtoNode::value(ConstructionArgs::Value(TaggedValue::U32(2)))),
|
(14, ProtoNode::value(ConstructionArgs::Value(crate::document::value::TaggedValue::U32(2)))),
|
||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.collect(),
|
.collect(),
|
||||||
@@ -739,7 +738,7 @@ mod test {
|
|||||||
DocumentNode {
|
DocumentNode {
|
||||||
name: "Value".into(),
|
name: "Value".into(),
|
||||||
inputs: vec![NodeInput::Value {
|
inputs: vec![NodeInput::Value {
|
||||||
tagged_value: value::TaggedValue::U32(2),
|
tagged_value: crate::document::value::TaggedValue::U32(2),
|
||||||
exposed: false,
|
exposed: false,
|
||||||
}],
|
}],
|
||||||
metadata: DocumentNodeMetadata::default(),
|
metadata: DocumentNodeMetadata::default(),
|
||||||
@@ -801,7 +800,10 @@ mod test {
|
|||||||
10,
|
10,
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
name: "Nested network".into(),
|
name: "Nested network".into(),
|
||||||
inputs: vec![NodeInput::value(TaggedValue::F32(1.), false), NodeInput::value(TaggedValue::F32(2.), false)],
|
inputs: vec![
|
||||||
|
NodeInput::value(crate::document::value::TaggedValue::F32(1.), false),
|
||||||
|
NodeInput::value(crate::document::value::TaggedValue::F32(2.), false),
|
||||||
|
],
|
||||||
metadata: DocumentNodeMetadata::default(),
|
metadata: DocumentNodeMetadata::default(),
|
||||||
implementation: DocumentNodeImplementation::Network(two_node_identity()),
|
implementation: DocumentNodeImplementation::Network(two_node_identity()),
|
||||||
},
|
},
|
||||||
@@ -834,7 +836,11 @@ mod test {
|
|||||||
assert_eq!(result.nodes.keys().copied().collect::<Vec<_>>(), vec![101], "Should just call nested network");
|
assert_eq!(result.nodes.keys().copied().collect::<Vec<_>>(), vec![101], "Should just call nested network");
|
||||||
let nested_network_node = result.nodes.get(&101).unwrap();
|
let nested_network_node = result.nodes.get(&101).unwrap();
|
||||||
assert_eq!(nested_network_node.name, "Nested network".to_string(), "Name should not change");
|
assert_eq!(nested_network_node.name, "Nested network".to_string(), "Name should not change");
|
||||||
assert_eq!(nested_network_node.inputs, vec![NodeInput::value(TaggedValue::F32(2.), false)], "Input should be 2");
|
assert_eq!(
|
||||||
|
nested_network_node.inputs,
|
||||||
|
vec![NodeInput::value(crate::document::value::TaggedValue::F32(2.), false)],
|
||||||
|
"Input should be 2"
|
||||||
|
);
|
||||||
let inner_network = nested_network_node.implementation.get_network().expect("Implementation should be network");
|
let inner_network = nested_network_node.implementation.get_network().expect("Implementation should be network");
|
||||||
assert_eq!(inner_network.inputs, vec![2], "The input should be sent to the second node");
|
assert_eq!(inner_network.inputs, vec![2], "The input should be sent to the second node");
|
||||||
assert_eq!(inner_network.outputs, vec![NodeOutput::new(2, 0)], "The output should be node id 2");
|
assert_eq!(inner_network.outputs, vec![NodeOutput::new(2, 0)], "The output should be node id 2");
|
||||||
@@ -853,7 +859,11 @@ mod test {
|
|||||||
for (node_id, input_value, inner_id) in [(10, 1., 1), (101, 2., 2)] {
|
for (node_id, input_value, inner_id) in [(10, 1., 1), (101, 2., 2)] {
|
||||||
let nested_network_node = result.nodes.get(&node_id).unwrap();
|
let nested_network_node = result.nodes.get(&node_id).unwrap();
|
||||||
assert_eq!(nested_network_node.name, "Nested network".to_string(), "Name should not change");
|
assert_eq!(nested_network_node.name, "Nested network".to_string(), "Name should not change");
|
||||||
assert_eq!(nested_network_node.inputs, vec![NodeInput::value(TaggedValue::F32(input_value), false)], "Input should be stable");
|
assert_eq!(
|
||||||
|
nested_network_node.inputs,
|
||||||
|
vec![NodeInput::value(crate::document::value::TaggedValue::F32(input_value), false)],
|
||||||
|
"Input should be stable"
|
||||||
|
);
|
||||||
let inner_network = nested_network_node.implementation.get_network().expect("Implementation should be network");
|
let inner_network = nested_network_node.implementation.get_network().expect("Implementation should be network");
|
||||||
assert_eq!(inner_network.inputs, vec![inner_id], "The input should be sent to the second node");
|
assert_eq!(inner_network.inputs, vec![inner_id], "The input should be sent to the second node");
|
||||||
assert_eq!(inner_network.outputs, vec![NodeOutput::new(inner_id, 0)], "The output should be node id");
|
assert_eq!(inner_network.outputs, vec![NodeOutput::new(inner_id, 0)], "The output should be node id");
|
||||||
@@ -872,7 +882,11 @@ mod test {
|
|||||||
assert_eq!(result_node.inputs, vec![NodeInput::node(101, 0)], "Result node should refer to duplicate node as input");
|
assert_eq!(result_node.inputs, vec![NodeInput::node(101, 0)], "Result node should refer to duplicate node as input");
|
||||||
let nested_network_node = result.nodes.get(&101).unwrap();
|
let nested_network_node = result.nodes.get(&101).unwrap();
|
||||||
assert_eq!(nested_network_node.name, "Nested network".to_string(), "Name should not change");
|
assert_eq!(nested_network_node.name, "Nested network".to_string(), "Name should not change");
|
||||||
assert_eq!(nested_network_node.inputs, vec![NodeInput::value(TaggedValue::F32(2.), false)], "Input should be 2");
|
assert_eq!(
|
||||||
|
nested_network_node.inputs,
|
||||||
|
vec![NodeInput::value(crate::document::value::TaggedValue::F32(2.), false)],
|
||||||
|
"Input should be 2"
|
||||||
|
);
|
||||||
let inner_network = nested_network_node.implementation.get_network().expect("Implementation should be network");
|
let inner_network = nested_network_node.implementation.get_network().expect("Implementation should be network");
|
||||||
assert_eq!(inner_network.inputs, vec![2], "The input should be sent to the second node");
|
assert_eq!(inner_network.inputs, vec![2], "The input should be sent to the second node");
|
||||||
assert_eq!(inner_network.outputs, vec![NodeOutput::new(2, 0)], "The output should be node id 2");
|
assert_eq!(inner_network.outputs, vec![NodeOutput::new(2, 0)], "The output should be node id 2");
|
||||||
|
|||||||
Reference in New Issue
Block a user