-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Enrich StreamReader and SinkWriter #5941
Enrich StreamReader and SinkWriter #5941
Conversation
6422cd8
to
90c89cf
Compare
tokio-util/src/io/copy_to_bytes.rs
Outdated
impl<S, T> Stream for CopyToBytes<S> | ||
where | ||
S: Stream<Item = T> + std::marker::Unpin, | ||
{ | ||
type Item = T; | ||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | ||
let ref_mut = self.get_mut().get_mut(); | ||
Pin::new(ref_mut).poll_next(cx) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want Unpin
bounds if they're not necessary. Also, the T
parameter can be dropped.
impl<S, T> Stream for CopyToBytes<S> | |
where | |
S: Stream<Item = T> + std::marker::Unpin, | |
{ | |
type Item = T; | |
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | |
let ref_mut = self.get_mut().get_mut(); | |
Pin::new(ref_mut).poll_next(cx) | |
} | |
} | |
impl<S: Stream> Stream for CopyToBytes<S> { | |
type Item = S::Item; | |
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | |
self.project().inner.poll_next(cx) | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also fix it for SinkWriter
and StreamReader
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
28257ef
to
109b46b
Compare
109b46b
to
83b564d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good to me!
Implementing feature suggested in issue #5745
Basically what was done is:
The implementation is pretty straightforward since the actual work is all demanded to the underlying object, so I thought that introducing new tests would not be really helpful.