chiark / gitweb /
wip refactor body, move type
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Aug 2021 17:49:08 +0000 (18:49 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Aug 2021 17:49:08 +0000 (18:49 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs

index 1d3328d83a6bf83c8582abae9ad42a883a0c1f56..fef184651afd0b00fdbf17b830e55baf57dd7b02 100644 (file)
@@ -68,27 +68,27 @@ fn submit_request<'r, 'c:'r, C:HCC>(
        "#),
   );
 
-  macro_rules! content {
-    {} => {
-      itertools::chain![
-        array::IntoIter::new([
-          Ok::<Bytes,Void>( prefix1.into() ),
-          Ok::<Bytes,Void>( prefix2.into() ),
-        ]).take(
-          if upbound.is_empty() { 1 } else { 2 }
-        ),
-        Itertools::intersperse(
-          upbound.into_iter().map(|u| Bytes::from(u)),
-          SLIP_END_SLICE.into()
-        ).map(Ok::<Bytes,Void>),
-        [ Ok::<Bytes,Void>( suffix.into() ) ],
-      ]
-    }
-  }
+  macro_rules! content { {
+    $out:ty
+  } => {
+    itertools::chain![
+      array::IntoIter::new([
+        Ok::<$out,Void>( prefix1.into() ),
+        Ok::<$out,Void>( prefix2.into() ),
+      ]).take(
+        if upbound.is_empty() { 1 } else { 2 }
+      ),
+      Itertools::intersperse(
+        upbound.into_iter().map(|u| { let out: $out = u.into(); out }),
+        SLIP_END_SLICE.into()
+      ).map(Ok::<$out,Void>),
+      [ Ok::<$out,Void>( suffix.into() ) ],
+    ]
+  }}
 
   let body = hyper::body::Body::wrap_stream(
     futures::stream::iter(
-      content!()
+      content!( Bytes )
     )
   );