diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-22 10:06:35 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-22 10:10:59 +0100 |
commit | 69a3335f1b79b074a0e1038bdfd9aa79508131d1 (patch) | |
tree | bb352dad39e880d11a1802b11c2a939e941a2ff6 /src/lib.rs | |
parent | 3d3e2ac6cdce593ab68c78d583f57905523a1591 (diff) |
refactor: support IntoIterMapCollect with N types
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -411,14 +411,14 @@ impl TypeTransform { quote! {#arg.map_err(|x| #err_inner)} } } - TypeTransform::CollectionOneType(type1) => { - let type1 = type1.convert(quote!(v1)); - quote! {#arg.into_iter().map(|v1| #type1).collect()} - } - TypeTransform::CollectionTwoTypes(type1, type2) => { - let type1 = type1.convert(quote!(v1)); - let type2 = type2.convert(quote!(v2)); - quote! {#arg.into_iter().map(|(v1,v2)| (#type1, #type2)).collect()} + TypeTransform::IntoIterMapCollect(types) => { + let idents = (0..types.len()).map(|i| format_ident!("v{}", i)); + // FUTURE: let transforms = std::iter::zip(idents, types).map(|(i, t)| t.convert(quote! {#i})); + let transforms = types.iter().enumerate().map(|(idx, t)| { + let id = format_ident!("v{}", idx); + t.convert(quote! {#id}) + }); + quote! {#arg.into_iter().map(|(#(#idents),*)| (#(#transforms),*)).collect()} } TypeTransform::NoOp => arg, } |