-
Notifications
You must be signed in to change notification settings - Fork 632
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
port futures 0.3 to std futures #1034
Conversation
04fbfd5
to
d87e9e3
Compare
this won't compile until a nightly with futures in it is built, but i think its ready to be looked at - theres a whole lot of extension traits which im kinda ambivalent about - i could just add more inherent methods in rust-lang/rust#51442 instead |
i have no idea whats causing those doc errors. a missing path in a link maybe? |
// } | ||
// } | ||
// } | ||
// } |
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.
Why was this removed?
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.
since either is defined in https://github.com/bluss/either and Future in std it can't exist here because of orphan rules - i might write a pr moving this to the either crate as an unstable feature
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.
I'd gently suggest removing the commented code, if it is, in fact, going away
futures-core/src/poll.rs
Outdated
fn is_ready(&self) -> bool; | ||
/// Returns whether this is `Poll::Pending` | ||
fn is_pending(&self) -> bool { | ||
!self.is_ready() |
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.
Your PR to core has been merged rust-lang/rust#51442 These methods are now not required
futures-core/src/lib.rs
Outdated
@@ -63,7 +64,7 @@ macro_rules! unsafe_unpinned { | |||
} | |||
|
|||
mod poll; | |||
pub use poll::Poll; | |||
pub use poll::{Poll, PollExt, PollResultExt}; |
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.
Also not required because core PR has been merged
rebased to latest nightly |
futures-core/src/future/mod.rs
Outdated
type Output = F::Output; | ||
impl<T: ?Sized> CoreFutureExt for T where T: Future {} | ||
|
||
// should be in std |
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.
This can be removed now, right?
futures-core/src/task/mod.rs
Outdated
fn drop(&mut self) { | ||
unsafe { | ||
(self.drop)(self.ptr) | ||
impl TaskObjExt for TaskObj { |
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.
This implements the trait for dyn TaskObj
-- did you mean to implement TaskObjExt
for T: TaskObj
?
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.
isn't TaskObj a struct that pretends to be a trait object currently?
futures-core/src/task/mod.rs
Outdated
(self.poll)(self.ptr, cx) | ||
} | ||
/// Extension trait for `TaskObj`, adding methods that require allocation. | ||
pub trait TaskObjExt { |
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.
What's the purpose of this trait? Since the method doesn't take self
, it's not actually callable using method syntax, so it might as well be a free function. IMO users should either call TaskObj::from_poll_task
directly or call the spawn
method on the ContextExt
trait.
futures-core/src/task/mod.rs
Outdated
impl<'a> ContextExt for Context<'a> { | ||
fn spawn<F>(&mut self, f: F) where F: Future<Output = ()> + 'static + Send { | ||
self.executor() | ||
.spawn_obj(TaskObj::new(f)).unwrap() |
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.
As I mentioned above, I'd change this to call from_poll_task
directly.
About reexports: I'm not sure whether we should offer reexports at all. Normally reexports are used for compatibility. However futures 0.3 can't be compatible with 0.2 in any meaningful way because nearly all signatures change a little bit. Therefore should there be reexports at all? I think we shouldn't offer reexports and instead encourage to either import the prelude or import from core directly. What do you think? |
How hard is it to preserve the re-export capability? It seems useful in the case where one isn't facing a compatibility issue. |
@Terkwood Please elaborate The reason I propose to remove the reexports is for consistency. It seems inconsistent to import |
Just to make sure I'm speaking coherently:
You're talking about removing reexports from the language entirely, right? If that's right: I think they're a mildly useful feature (in theory). Coming from a background in other languages, I liked the idea of having this facility available for use in lieu of writing boilerplate wrapper code. I don't want to express too much enthusiasm for the reexport feature in rust. Futures are a big deal. Your statement in favor of consistency is good. If the only way that reexports can be kept in the language will involve introducing a confusing inconsistency in their use, then... meh? That's not very appealing, when you put it that way, no. Thanks for your time and effort! |
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.
Thank you!
// } | ||
// } | ||
// } | ||
// } |
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.
I'd gently suggest removing the commented code, if it is, in fact, going away
/// the `fuse` adaptor which defines the behavior of `poll`, but comes with | ||
/// a little bit of extra cost. | ||
fn poll(self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output>; | ||
pub use core::future::Future; |
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.
🎉
@Terkwood No no ^^' I merely suggest to remove the reexport statements in futures-core. In other words: Only export the stuff that is actually defined in futures-core (e.g. |
Oh, ok😀
Then my earlier comment was misinformed. Thanks for bearing with me! Please
proceed!
…On Sun, Jun 17, 2018, 13:34 Josef Brandl ***@***.***> wrote:
You're talking about removing reexports from the language entirely, right?
@Terkwood <https://github.com/Terkwood> No no ^^' I merely suggest to
remove the reexport statements in futures-core. In other words: Only export
the stuff that is actually defined in futures-core (e.g. Stream)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1034 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AlDziCTScHqAYFTjRaYqrT6aRAx-sAVyks5t9pMUgaJpZM4UfEoo>
.
|
The re-export is important for getting futures 0.3 on stable faster. As soon as |
@withoutboats That requires:
|
It was decided in a quick discussion on the wg-net Discord channel to leave the reexports in, because they give us the possibility to maybe do the "stable shim dance" later |
Merged, thanks much @tinaun! There are a couple of minor things I will clean up in a follow-up PR. |
No description provided.