MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / expand

Function expand

flow-derive/src/ports.rs:93–116  ·  view source on GitHub ↗
(ports: &PortSequence, extend_ty: &str)

Source from the content-addressed store, hash-verified

91}
92
93fn expand(ports: &PortSequence, extend_ty: &str) -> Vec<TokenStream> {
94 let extend_ty = lit::ident(extend_ty);
95 ports
96 .fields
97 .iter()
98 .map(|port| {
99 let Port { name, ty } = port;
100 match ty {
101 PortType::Unit => {
102 quote_spanned!(name.span()=> #name: flow_rs::channel::#extend_ty)
103 }
104 PortType::List => {
105 quote_spanned!(name.span()=> #name: Vec<flow_rs::channel::#extend_ty>)
106 }
107 PortType::Dict => {
108 quote_spanned!(name.span()=> #name: std::collections::HashMap<u64, flow_rs::channel::#extend_ty>)
109 }
110 PortType::Dyn => {
111 quote_spanned!(name.span()=> #name: flow_rs::node::DynPorts<flow_rs::channel::#extend_ty>)
112 }
113 }
114 })
115 .collect()
116}
117
118pub fn name_expand(ports: &PortSequence) -> Vec<LitStr> {
119 ports

Callers 2

in_expandFunction · 0.70
out_expandFunction · 0.70

Calls 1

identFunction · 0.85

Tested by

no test coverage detected