MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / collect_generics

Function collect_generics

node-graph/graph-craft/src/proto.rs:846–859  ·  view source on GitHub ↗

Returns a list of all generic types used in the node

(types: &NodeIOTypes)

Source from the content-addressed store, hash-verified

844
845/// Returns a list of all generic types used in the node
846fn collect_generics(types: &NodeIOTypes) -> Vec<Cow<'static, str>> {
847 let inputs = [&types.call_argument].into_iter().chain(types.inputs.iter().map(|x| x.nested_type()));
848 let mut generics = inputs
849 .filter_map(|t| match t {
850 Type::Generic(out) => Some(out.clone()),
851 _ => None,
852 })
853 .collect::<Vec<_>>();
854 if let Type::Generic(out) = &types.return_value {
855 generics.push(out.clone());
856 }
857 generics.dedup();
858 generics
859}
860
861/// Checks if a generic type can be substituted with a concrete type and returns the concrete type
862fn check_generic(types: &NodeIOTypes, input: &Type, parameters: &[Type], generic: &str) -> Result<Type, String> {

Callers 1

inferMethod · 0.85

Calls 5

nested_typeMethod · 0.80
into_iterMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected