Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add stream::peekable #366

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

Draft
starsheriff wants to merge 8 commits into async-rs:main
base: main
Choose a base branch
Loading
from starsheriff:stream_peekable
Draft

Conversation

Copy link
Contributor

@starsheriff starsheriff commented Oct 17, 2019
edited
Loading

Currently everything is breaking. I am still trying to figure out the type. I guess that peek should return a Future

pub fn peak(&mut self) -> &PeekFuture<Option<Self::Item>>

ref #129

}
None => {
let next = futures_core::ready!(self.as_mut().stream().poll_next(cx));
match next {
Copy link
Contributor

@yjhmelody yjhmelody Oct 23, 2019

Choose a reason for hiding this comment

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

match is redundant.

Copy link
Contributor

@yjhmelody yjhmelody Oct 23, 2019

Choose a reason for hiding this comment

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

Poll::Ready(next)

Some(_) => {
let v = Poll::Ready(self.as_mut().peeked().take().unwrap());
*self.as_mut().peeked() = None;
v
Copy link
Contributor

@yjhmelody yjhmelody Oct 23, 2019

Choose a reason for hiding this comment

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

In my opinion, the peeked just should hold the next. And every poll_next, it will be changed to new next. Why do *self.as_mut().peeked() = None;

S: Stream,
{
pin_utils::unsafe_pinned!(stream: S);
pin_utils::unsafe_unpinned!(peeked: Option<Option<S::Item>>);
Copy link
Contributor

@yoshuawuyts yoshuawuyts Oct 28, 2019

Choose a reason for hiding this comment

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

It'd be nice if this could be updated to use pin-project-lite the way we've done for other combinators (we merged this in the last week; in general it should be nicer!)

Copy link
Contributor

@starsheriff ping; just checking in if there's anything we can do to help unblock you. I'd very much would like to see this PR land!

@yoshuawuyts yoshuawuyts added the enhancement New feature or request label Oct 28, 2019
Copy link
Contributor Author

@starsheriff ping; just checking in if there's anything we can do to help unblock you. I'd very much would like to see this PR land!

The comments I got helped a lot already. Haven't had the time the last days to work on it but will pick it up again now. I will ask if I need more help.

yoshuawuyts reacted with hooray emoji

S: Sized,
{
stream: S,
peeked: Option<Poll<Option<S::Item>>>,
Copy link
Contributor Author

@starsheriff starsheriff Oct 29, 2019

Choose a reason for hiding this comment

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

this is what I landed on as the value for peeked

match &self.peeked {
Some(peeked) => &peeked,
None => {
// how to get the next `next` value? What about `Context`
Copy link
Contributor Author

@starsheriff starsheriff Oct 29, 2019

Choose a reason for hiding this comment

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

this is where I currently have troubles @yoshuawuyts , I have no idea how to get the next next value from here. Given that I store a Option<Poll<Option<S::Item>>> in the struct.

@yoshuawuyts yoshuawuyts mentioned this pull request Nov 15, 2019
87 tasks
Copy link
Contributor

@starsheriff The peek seem to be diffcult to impl. And if things are async, I think the peek is not very
useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@yoshuawuyts yoshuawuyts yoshuawuyts left review comments

+1 more reviewer

@yjhmelody yjhmelody yjhmelody left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
enhancement New feature or request
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /