Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Extend<Bytes> for BytesMut #527

Merged
merged 1 commit into from Jan 24, 2022

Conversation

robjtede
Copy link
Sponsor Contributor

@robjtede robjtede commented Jan 24, 2022

Motivation

This lets us play nice with Stream's methods like:

fn get_stream() -> impl Stream<Item = Bytes> { todo!() };
let payload = get_stream().collect::<BytesMut>().await;
fn get_stream() -> impl Stream<Item = Result<Bytes, E>> { todo!() };
let payload = get_stream().try_collect::<BytesMut>().await?;

Since the bound on this collect is a bit different to std's iter collect which is based on FromIterator.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@Darksonn Darksonn merged commit 131dae1 into tokio-rs:master Jan 24, 2022
@robjtede robjtede deleted the extend-mut-from-bytes branch January 24, 2022 09:01
lelongg pushed a commit to lelongg/bytes that referenced this pull request Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants