From 49eeef3fe14b11c78b04525825349f5155edfeab Mon Sep 17 00:00:00 2001 From: Kurnia D Win Date: Tue, 1 Dec 2020 10:19:12 +0700 Subject: [PATCH 1/2] Do not expose PollFn struct We don't need to expose PollFn struct to the public, returning `impl Future` is enought --- library/core/src/future/poll_fn.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/future/poll_fn.rs b/library/core/src/future/poll_fn.rs index af63e1bb097b8..7564fd3febc86 100644 --- a/library/core/src/future/poll_fn.rs +++ b/library/core/src/future/poll_fn.rs @@ -24,7 +24,7 @@ use crate::task::{Context, Poll}; /// # } /// ``` #[unstable(feature = "future_poll_fn", issue = "72302")] -pub fn poll_fn(f: F) -> PollFn +pub fn poll_fn(f: F) -> impl Future where F: FnMut(&mut Context<'_>) -> Poll, { @@ -37,7 +37,7 @@ where /// documentation for more. #[must_use = "futures do nothing unless you `.await` or poll them"] #[unstable(feature = "future_poll_fn", issue = "72302")] -pub struct PollFn { +struct PollFn { f: F, } From 52310f7377af297ffefd9004430223302fc6793c Mon Sep 17 00:00:00 2001 From: Kurnia D Win Date: Tue, 1 Dec 2020 10:27:43 +0700 Subject: [PATCH 2/2] Update mod.rs --- library/core/src/future/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/future/mod.rs b/library/core/src/future/mod.rs index cdde094147012..ee547667c349d 100644 --- a/library/core/src/future/mod.rs +++ b/library/core/src/future/mod.rs @@ -27,7 +27,7 @@ pub use pending::{pending, Pending}; pub use ready::{ready, Ready}; #[unstable(feature = "future_poll_fn", issue = "72302")] -pub use poll_fn::{poll_fn, PollFn}; +pub use poll_fn::poll_fn; /// This type is needed because: ///