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

Function extract_ports

flow-derive/src/utils.rs:90–106  ·  view source on GitHub ↗
(
    data: &syn::Data,
    ty_name: &str,
    f: fn(ExtractParams) -> TokenStream,
)

Source from the content-addressed store, hash-verified

88pub type ExtractParams<'a> = (&'a Ident, &'a Option<Ident>, &'a Type);
89
90pub fn extract_ports(
91 data: &syn::Data,
92 ty_name: &str,
93 f: fn(ExtractParams) -> TokenStream,
94) -> Vec<TokenStream> {
95 let port_func = lit::ident(ty_name.to_lowercase());
96 fields(data)
97 .filter(|field| {
98 match_last_ty(&field.ty, ty_name)
99 || last_inner_ty(&field.ty)
100 .map(|inner_ty| match_last_ty(inner_ty, ty_name))
101 .unwrap_or(false)
102 })
103 .map(|field| (&port_func, &field.ident, &field.ty))
104 .map(f)
105 .collect()
106}

Callers 2

expandFunction · 0.85
expandFunction · 0.85

Calls 5

identFunction · 0.85
fieldsFunction · 0.85
match_last_tyFunction · 0.85
last_inner_tyFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected