-
Notifications
You must be signed in to change notification settings - Fork 626
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
Smaller await #1159
Smaller await #1159
Changes from all commits
57a26f2
bc55ee8
18abba1
1be17b3
4e3f0d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,5 @@ mod join; | |
mod select; | ||
|
||
#[doc(hidden)] | ||
#[inline(always)] | ||
pub fn assert_unpin<T: Future + Unpin>(_: &T) {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,16 +47,18 @@ macro_rules! select { | |
)* | ||
} | ||
|
||
let __priv_res = loop { | ||
let __priv_res = await!($crate::future::poll_fn(|cx| { | ||
$( | ||
let poll_res = $crate::poll!($crate::core_reexport::mem::PinMut::new( | ||
&mut $name)); | ||
if let $crate::core_reexport::task::Poll::Ready(x) = poll_res { | ||
break __PrivResult::$name(x); | ||
match $crate::core_reexport::future::Future::poll( | ||
$crate::core_reexport::mem::PinMut::new(&mut $name), cx) | ||
{ | ||
$crate::core_reexport::task::Poll::Ready(x) => | ||
return $crate::core_reexport::task::Poll::Ready(__PrivResult::$name(x)), | ||
$crate::core_reexport::task::Poll::Pending => {}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this branch is empty, you could use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I intentionally changed it because I think it's easier to read as a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd have introduced a |
||
} | ||
)* | ||
$crate::pending!(); | ||
}; | ||
$crate::core_reexport::task::Poll::Pending | ||
})); | ||
match __priv_res { | ||
$( | ||
__PrivResult::$name($name) => { | ||
|
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.
It's basically:
You could give back the value from the expression above directly
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.
It's intentionally done this way in order to provide the
: Result<_, _>
annotation .