diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-23 06:00:26 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-23 06:43:22 +0100 |
commit | 19dcb405cd4cfb960f51edbc1446e0a843772d6b (patch) | |
tree | fbd4a80460a20faea6975ae51939f463b612a6e3 /src/lib.rs | |
parent | b4acbbf52be85595cf8dcb839217fc4e2958328e (diff) |
support tuples
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -473,6 +473,15 @@ impl TypeTransform { quote! {#arg.map_err(|x| #err_inner)} } } + TypeTransform::Tuple(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! { {let (#(#idents),*) = #arg; (#(#transforms),*)} } + } 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})); |