mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Fix import being lost when running 'cargo fix' due to feature flag
This commit is contained in:
parent
5748d9bff4
commit
7f4602ed20
1 changed files with 24 additions and 10 deletions
|
@ -1,4 +1,3 @@
|
|||
use crate::document::value::TaggedValue;
|
||||
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
|
||||
use graphene_core::{NodeIdentifier, Type};
|
||||
|
||||
|
@ -126,7 +125,7 @@ impl DocumentNode {
|
|||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum NodeInput {
|
||||
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),
|
||||
}
|
||||
|
||||
|
@ -137,7 +136,7 @@ impl NodeInput {
|
|||
pub const fn lambda(node_id: NodeId, output_index: usize) -> Self {
|
||||
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 }
|
||||
}
|
||||
fn map_ids(&mut self, f: impl Fn(NodeId) -> NodeId) {
|
||||
|
@ -632,7 +631,7 @@ mod test {
|
|||
inputs: vec![
|
||||
NodeInput::Network(concrete!(u32)),
|
||||
NodeInput::Value {
|
||||
tagged_value: value::TaggedValue::U32(2),
|
||||
tagged_value: crate::document::value::TaggedValue::U32(2),
|
||||
exposed: false,
|
||||
},
|
||||
],
|
||||
|
@ -698,7 +697,7 @@ mod test {
|
|||
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()
|
||||
.collect(),
|
||||
|
@ -739,7 +738,7 @@ mod test {
|
|||
DocumentNode {
|
||||
name: "Value".into(),
|
||||
inputs: vec![NodeInput::Value {
|
||||
tagged_value: value::TaggedValue::U32(2),
|
||||
tagged_value: crate::document::value::TaggedValue::U32(2),
|
||||
exposed: false,
|
||||
}],
|
||||
metadata: DocumentNodeMetadata::default(),
|
||||
|
@ -801,7 +800,10 @@ mod test {
|
|||
10,
|
||||
DocumentNode {
|
||||
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(),
|
||||
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");
|
||||
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.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");
|
||||
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");
|
||||
|
@ -853,7 +859,11 @@ mod test {
|
|||
for (node_id, input_value, inner_id) in [(10, 1., 1), (101, 2., 2)] {
|
||||
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.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");
|
||||
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");
|
||||
|
@ -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");
|
||||
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.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");
|
||||
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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue