From 1762de285b8bd96eed278c6c0bf8b13edc5d0b62 Mon Sep 17 00:00:00 2001 From: k-nasa Date: Thu, 16 Jan 2020 15:40:28 +0900 Subject: [PATCH] feat: Make the future module no_std --- src/future/future/mod.rs | 6 +++--- src/future/mod.rs | 21 +++++++++++++-------- src/lib.rs | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/future/future/mod.rs b/src/future/future/mod.rs index d610096..24f3fb5 100644 --- a/src/future/future/mod.rs +++ b/src/future/future/mod.rs @@ -21,8 +21,8 @@ cfg_unstable_default! { } extension_trait! { - use std::pin::Pin; - use std::ops::{Deref, DerefMut}; + use core::pin::Pin; + use core::ops::{Deref, DerefMut}; use crate::task::{Context, Poll}; @@ -136,7 +136,7 @@ extension_trait! { [`Future`]: ../future/trait.Future.html "#] - pub trait FutureExt: std::future::Future { + pub trait FutureExt: core::future::Future { /// Returns a Future that delays execution for a specified time. /// /// # Examples diff --git a/src/future/mod.rs b/src/future/mod.rs index 9936276..3d325be 100644 --- a/src/future/mod.rs +++ b/src/future/mod.rs @@ -46,15 +46,20 @@ //! [`Future::race`]: trait.Future.html#method.race //! [`Future::try_race`]: trait.Future.html#method.try_race -pub use future::Future; -pub use pending::pending; -pub use poll_fn::poll_fn; -pub use ready::ready; +cfg_no_std! { + pub use future::Future; + pub(crate) mod future; +} + +cfg_std! { + pub use pending::pending; + pub use poll_fn::poll_fn; + pub use ready::ready; -pub(crate) mod future; -mod pending; -mod poll_fn; -mod ready; + mod pending; + mod poll_fn; + mod ready; +} cfg_default! { pub use timeout::{timeout, TimeoutError}; diff --git a/src/lib.rs b/src/lib.rs index fc0755d..6fe13e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -243,10 +243,10 @@ mod macros; cfg_no_std! { pub mod task; + pub mod future; } cfg_std! { - pub mod future; pub mod io; pub mod os; pub mod prelude;