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

Function set_f

flow-derive/src/node.rs:49–71  ·  view source on GitHub ↗
((port_func, ident, ty): IterArgs)

Source from the content-addressed store, hash-verified

47 let ident = input.ident;
48 type IterArgs<'a> = ExtractParams<'a>;
49 fn set_f((port_func, ident, ty): IterArgs) -> TokenStream {
50 if match_last_ty(ty, "Vec") {
51 quote_spanned! {ident.span()=>
52 if port_name == concat!('[', stringify!(#ident), ']') {
53 self.#ident.push(channel.#port_func());
54 } else
55 }
56 } else if match_last_ty(ty, "HashMap") {
57 quote_spanned! {ident.span()=>
58 if port_name == concat!('{', stringify!(#ident), '}') {
59 self.#ident.insert(tag.expect("dict port need a tag"), channel.#port_func());
60 } else
61 }
62 } else if match_last_ty(ty, "DynPorts") {
63 quote! {}
64 } else {
65 quote_spanned! {ident.span()=>
66 if port_name == stringify!(#ident) {
67 self.#ident = channel.#port_func();
68 } else
69 }
70 }
71 }
72 fn set_dyn_f((_, ident, ty): IterArgs) -> TokenStream {
73 if match_last_ty(ty, "DynPorts") {
74 quote_spanned! {ident.span()=>

Callers

nothing calls this directly

Calls 1

match_last_tyFunction · 0.85

Tested by

no test coverage detected