Skip to content

Commit 130ef40

Browse files
committed
Use new async || closure syntax 🎉
1 parent bf42752 commit 130ef40

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ You can build a [`Sipper`] with the [`sipper`] function. It takes a closure that
147147
a [`Sender`]—for sending progress updates—and must return a [`Future`] producing the output.
148148

149149
```rust
150-
fn download(url: &str) -> impl Sipper<File, Progress> + '_ {
151-
sipper(|mut sender| async move {
150+
fn download(url: &str) -> impl Sipper<File, Progress> {
151+
sipper(async move |mut sender| {
152152
// Perform async request here...
153153
let download = /* ... */;
154154

@@ -177,8 +177,8 @@ For instance, let's say we wanted to build a new function that downloads a bunch
177177
instead of just one:
178178

179179
```rust
180-
fn download_all<'a>(urls: &'a [&str]) -> impl Sipper<Vec<File>, (usize, Progress)> + 'a {
181-
sipper(move |sender| async move {
180+
fn download_all(urls: &[&str]) -> impl Sipper<Vec<File>, (usize, Progress)> {
181+
sipper(async move |sender| {
182182
let mut files = Vec::new();
183183

184184
for (id, url) in urls.iter().enumerate() {
@@ -205,7 +205,7 @@ more! Take a look:
205205
```rust
206206
use futures::stream::{FuturesOrdered, StreamExt};
207207

208-
fn download_all<'a>(urls: &'a [&str]) -> impl Sipper<Vec<File>, (usize, Progress)> + 'a {
208+
fn download_all(urls: &[&str]) -> impl Sipper<Vec<File>, (usize, Progress)> {
209209
sipper(|sender| {
210210
urls.iter()
211211
.enumerate()

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
//! #
179179
//! # type Progress = u32;
180180
//! #
181-
//! fn download(url: &str) -> impl Sipper<File, Progress> + '_ {
181+
//! fn download(url: &str) -> impl Sipper<File, Progress> {
182182
//! sipper(|mut sender| async move {
183183
//! // Perform async request here...
184184
//! let download = /* ... */;
@@ -218,8 +218,8 @@
218218
//! # sipper(|_| futures::future::ready(File(Vec::new())))
219219
//! # }
220220
//! #
221-
//! fn download_all<'a>(urls: &'a [&str]) -> impl Sipper<Vec<File>, (usize, Progress)> + 'a {
222-
//! sipper(move |sender| async move {
221+
//! fn download_all(urls: &[&str]) -> impl Sipper<Vec<File>, (usize, Progress)> {
222+
//! sipper(async move |sender| {
223223
//! let mut files = Vec::new();
224224
//!
225225
//! for (id, url) in urls.iter().enumerate() {
@@ -256,7 +256,7 @@
256256
//! #
257257
//! use futures::stream::{FuturesOrdered, StreamExt};
258258
//!
259-
//! fn download_all<'a>(urls: &'a [&str]) -> impl Sipper<Vec<File>, (usize, Progress)> + 'a {
259+
//! fn download_all(urls: &[&str]) -> impl Sipper<Vec<File>, (usize, Progress)> {
260260
//! sipper(|sender| {
261261
//! urls.iter()
262262
//! .enumerate()
@@ -504,7 +504,7 @@ mod tests {
504504
Failed,
505505
}
506506

507-
fn download(url: &str) -> impl Sipper<File, Progress> + '_ {
507+
fn download(url: &str) -> impl Sipper<File, Progress> {
508508
sipper(async move |mut sender| {
509509
let _url = url;
510510

@@ -516,7 +516,7 @@ mod tests {
516516
})
517517
}
518518

519-
fn try_download(url: &str) -> impl Straw<File, Progress, Error> + '_ {
519+
fn try_download(url: &str) -> impl Straw<File, Progress, Error> {
520520
sipper(async move |mut sender| {
521521
let _url = url;
522522

@@ -688,7 +688,7 @@ mod tests {
688688
async fn it_composes_nicely() {
689689
use futures::stream::{FuturesOrdered, StreamExt};
690690

691-
fn download_all<'a>(urls: &'a [&str]) -> impl Sipper<Vec<File>, (usize, Progress)> + 'a {
691+
fn download_all(urls: &[&str]) -> impl Sipper<Vec<File>, (usize, Progress)> {
692692
sipper(|sender| {
693693
urls.iter()
694694
.enumerate()

0 commit comments

Comments
 (0)