Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

yield_entire_stream!(stream) #77

Open
manuels opened this issue Mar 21, 2018 · 2 comments
Open

yield_entire_stream!(stream) #77

manuels opened this issue Mar 21, 2018 · 2 comments

Comments

@manuels
Copy link

manuels commented Mar 21, 2018

Sometimes you want to yield all items of a stream and yield some additional elements afterwards.
Something like

#[async]
for item in stream_a {
    stream_yield!(item)
}

#[async]
for item in stream_b {
    stream_yield!(item)
}

stream_yield!(0u8);
Ok(())

I would like to propose to add an additional macro that transform the code above to

yield_entire_stream!(stream_a);
yield_entire_stream!(stream_b);

stream_yield!(0u8);
Ok(())

Although I am open to rename the macro ;)

@anthonyclays
Copy link

In Python, this is done using the yield from ... syntax. I'd propose stream_yield_from!(stream_a) to match that.

@manuels
Copy link
Author

manuels commented Apr 3, 2018

@anthonyclays, great idea!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants