Merge pull request #680 from k-nasa/no_std

Some modules support no_std
split-by-pattern
Yoshua Wuyts 5 years ago committed by GitHub
commit 125fa5b0a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,6 +40,7 @@ jobs:
with:
command: check
args: --features unstable --all --bins --examples --tests
- name: check bench
uses: actions-rs/cargo@v1
if: matrix.rust == 'nightly'
@ -71,6 +72,24 @@ jobs:
command: test
args: --doc --features "unstable attributes"
build__with_no_std:
name: Build with no-std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: setup
run: |
rustup default nightly
rustup target add thumbv7m-none-eabi
- name: check no_std
uses: actions-rs/cargo@v1
with:
command: check
args: --no-default-features --features alloc --target thumbv7m-none-eabi -Z avoid-dev-deps
check_fmt_and_docs:
name: Checking fmt and docs
runs-on: ubuntu-latest

@ -38,15 +38,19 @@ docs = ["attributes", "unstable", "default"]
unstable = ["std", "broadcaster", "futures-timer"]
attributes = ["async-attributes"]
std = [
"alloc",
"crossbeam-utils",
"futures-core",
"futures-core/std",
"futures-io",
"memchr",
"once_cell",
"pin-project-lite",
"pin-utils",
"slab",
]
alloc = [
"futures-core/alloc",
"pin-project-lite",
]
[dependencies]
async-attributes = { version = "1.1.1", optional = true }
@ -55,7 +59,7 @@ broadcaster = { version = "1.0.0", optional = true }
crossbeam-channel = { version = "0.4.0", optional = true }
crossbeam-deque = { version = "0.7.2", optional = true }
crossbeam-utils = { version = "0.7.0", optional = true }
futures-core = { version = "0.3.1", optional = true }
futures-core = { version = "0.3.1", optional = true, default-features = false }
futures-io = { version = "0.3.1", optional = true }
futures-timer = { version = "2.0.2", optional = true }
kv-log-macro = { version = "1.0.4", optional = true }

@ -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

@ -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_alloc! {
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};

@ -221,6 +221,7 @@
//! features = ["std"]
//! ```
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "docs", feature(doc_cfg))]
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![allow(clippy::mutex_atomic, clippy::module_inception)]
@ -229,6 +230,8 @@
#![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")]
#![recursion_limit = "2048"]
extern crate alloc;
#[macro_use]
mod utils;
@ -240,14 +243,17 @@ pub use async_attributes::{main, test};
#[cfg(feature = "std")]
mod macros;
cfg_std! {
cfg_alloc! {
pub mod task;
pub mod future;
pub mod stream;
}
cfg_std! {
pub mod io;
pub mod os;
pub mod prelude;
pub mod stream;
pub mod sync;
pub mod task;
}
cfg_default! {

@ -1,5 +1,5 @@
use std::pin::Pin;
use std::future::Future;
use core::pin::Pin;
use core::future::Future;
use crate::stream::DoubleEndedStream;
use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use core::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};
use crate::stream::DoubleEndedStream;

@ -1,6 +1,6 @@
use std::task::{Context, Poll};
use std::future::Future;
use std::pin::Pin;
use core::task::{Context, Poll};
use core::future::Future;
use core::pin::Pin;
use crate::stream::DoubleEndedStream;

@ -1,6 +1,6 @@
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use core::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use crate::future::Future;
use std::pin::Pin;
use core::pin::Pin;
use crate::task::{Context, Poll};
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::marker::PhantomData;
use std::pin::Pin;
use core::marker::PhantomData;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::pin::Pin;
use core::pin::Pin;
use core::future::Future;
use crate::prelude::*;
use crate::stream::IntoStream;
/// Extends a collection with the contents of a stream.

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use core::future::Future;
use core::pin::Pin;
use crate::stream::IntoStream;

@ -2,10 +2,10 @@ use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::{Duration, Instant};
use crate::future::Future;
use crate::stream::Stream;
use futures_timer::Delay;
use crate::prelude::*;
/// Creates a new stream that yields at a set interval.
///
/// The stream first yields after `dur`, and continues to yield every

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::marker::PhantomData;
use std::pin::Pin;
use std::task::{Context, Poll};
use core::marker::PhantomData;
use core::pin::Pin;
use core::task::{Context, Poll};
use crate::stream::{DoubleEndedStream, ExactSizeStream, FusedStream, Stream};

@ -1,5 +1,5 @@
use std::pin::Pin;
use std::future::Future;
use core::pin::Pin;
use core::future::Future;
use crate::stream::Stream;

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::marker::PhantomData;
use std::pin::Pin;
use std::future::Future;
use core::marker::PhantomData;
use core::pin::Pin;
use core::future::Future;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::marker::PhantomData;
use std::pin::Pin;
use std::future::Future;
use core::marker::PhantomData;
use core::pin::Pin;
use core::future::Future;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,9 +1,10 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;
use super::fuse::Fuse;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll};
pin_project! {

@ -1,7 +1,7 @@
use crate::stream::Stream;
use crate::task::{Context, Poll};
use pin_project_lite::pin_project;
use std::pin::Pin;
use core::pin::Pin;
pin_project! {
/// A stream that clones the elements of an underlying stream.

@ -1,11 +1,11 @@
use std::cmp::Ordering;
use std::pin::Pin;
use std::future::Future;
use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;
use super::fuse::Fuse;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,7 +1,7 @@
use crate::stream::Stream;
use crate::task::{Context, Poll};
use pin_project_lite::pin_project;
use std::pin::Pin;
use core::pin::Pin;
pin_project! {
/// A stream that copies the elements of an underlying stream.

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::mem::ManuallyDrop;
use std::pin::Pin;
use core::mem::ManuallyDrop;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::future::Future;
use std::pin::Pin;
use std::time::Duration;
use core::future::Future;
use core::pin::Pin;
use core::time::Duration;
use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,10 +1,10 @@
use std::pin::Pin;
use std::future::Future;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;
use super::fuse::Fuse;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::pin::Pin;
use std::task::{Context, Poll};
use core::pin::Pin;
use core::task::{Context, Poll};
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use core::future::Future;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use core::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};
use crate::stream::Stream;

@ -1,9 +1,9 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;
use crate::prelude::*;
use crate::stream::stream::map::Map;
use crate::stream::stream::StreamExt;
use crate::stream::{IntoStream, Stream};
use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::fmt;
use std::pin::Pin;
use core::fmt;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::pin::Pin;
use std::future::Future;
use core::pin::Pin;
use core::future::Future;
use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,11 +1,11 @@
use std::cmp::Ordering;
use std::pin::Pin;
use std::future::Future;
use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;
use super::partial_cmp::PartialCmpFuture;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,11 +1,11 @@
use std::cmp::Ordering;
use std::pin::Pin;
use std::future::Future;
use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;
use super::partial_cmp::PartialCmpFuture;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,11 +1,11 @@
use std::cmp::Ordering;
use std::pin::Pin;
use std::future::Future;
use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;
use super::partial_cmp::PartialCmpFuture;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,11 +1,11 @@
use std::cmp::Ordering;
use std::pin::Pin;
use std::future::Future;
use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;
use super::partial_cmp::PartialCmpFuture;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,7 +1,7 @@
use std::cmp::{Ord, Ordering};
use std::marker::PhantomData;
use std::pin::Pin;
use std::future::Future;
use core::cmp::{Ord, Ordering};
use core::marker::PhantomData;
use core::pin::Pin;
use core::future::Future;
use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::cmp::Ordering;
use std::pin::Pin;
use std::future::Future;
use core::cmp::Ordering;
use core::pin::Pin;
use core::future::Future;
use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::cmp::Ordering;
use std::future::Future;
use std::pin::Pin;
use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,10 +1,11 @@
use std::pin::Pin;
use std::task::{Context, Poll};
use core::pin::Pin;
use core::task::{Context, Poll};
use pin_project_lite::pin_project;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Fuse;
use crate::stream::Stream;
use crate::utils;
pin_project! {

@ -1,7 +1,7 @@
use std::cmp::{Ord, Ordering};
use std::marker::PhantomData;
use std::pin::Pin;
use std::future::Future;
use core::cmp::{Ord, Ordering};
use core::marker::PhantomData;
use core::pin::Pin;
use core::future::Future;
use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::cmp::Ordering;
use std::pin::Pin;
use std::future::Future;
use core::cmp::Ordering;
use core::pin::Pin;
use core::future::Future;
use pin_project_lite::pin_project;

@ -1,6 +1,6 @@
use std::cmp::Ordering;
use std::future::Future;
use std::pin::Pin;
use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -110,12 +110,12 @@ pub use take::Take;
pub use take_while::TakeWhile;
pub use zip::Zip;
use std::cmp::Ordering;
use core::cmp::Ordering;
cfg_unstable! {
use std::future::Future;
use std::pin::Pin;
use std::time::Duration;
use core::future::Future;
use core::pin::Pin;
use core::time::Duration;
use crate::stream::into_stream::IntoStream;
use crate::stream::{FromStream, Product, Sum};

@ -1,10 +1,10 @@
use std::pin::Pin;
use std::future::Future;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;
use super::fuse::Fuse;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::pin::Pin;
use std::future::Future;
use core::pin::Pin;
use core::future::Future;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,6 +1,6 @@
use std::pin::Pin;
use std::task::{Context, Poll};
use std::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};
use core::future::Future;
use crate::stream::Stream;

@ -1,11 +1,11 @@
use std::cmp::Ordering;
use std::future::Future;
use std::pin::Pin;
use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;
use super::fuse::Fuse;
use crate::prelude::*;
use crate::stream::stream::StreamExt;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,7 +1,7 @@
use pin_project_lite::pin_project;
use std::default::Default;
use std::future::Future;
use std::pin::Pin;
use core::default::Default;
use core::future::Future;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use core::future::Future;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::pin::Pin;
use std::task::{Context, Poll};
use core::pin::Pin;
use core::task::{Context, Poll};
use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,8 +1,8 @@
use std::error::Error;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::time::Duration;
use std::future::Future;
use futures_timer::Delay;
use pin_project_lite::pin_project;

@ -1,4 +1,4 @@
use std::pin::Pin;
use core::pin::Pin;
use crate::future::Future;
use crate::stream::Stream;

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use core::future::Future;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::fmt;
use std::pin::Pin;
use core::fmt;
use core::pin::Pin;
use pin_project_lite::pin_project;

@ -1,5 +1,5 @@
use std::mem;
use std::pin::Pin;
use core::mem;
use core::pin::Pin;
use crate::stream::Stream;
use crate::task::{Context, Poll};

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use core::future::Future;
use core::pin::Pin;
use crate::stream::Stream;

@ -117,13 +117,16 @@
//! [`task_local!`]: ../macro.task_local.html
//! [`with`]: struct.LocalKey.html#method.with
cfg_std! {
cfg_alloc! {
#[doc(inline)]
pub use std::task::{Context, Poll, Waker};
pub use core::task::{Context, Poll, Waker};
pub use ready::ready;
pub use yield_now::yield_now;
mod ready;
}
cfg_std! {
pub use yield_now::yield_now;
mod yield_now;
}

@ -1,3 +1,5 @@
use alloc::string::String;
/// Calls a function and aborts if it panics.
///
/// This is useful in unsafe code where we can't recover from panics.
@ -104,6 +106,7 @@ macro_rules! cfg_unstable_default {
/// Declares Unix-specific items.
#[doc(hidden)]
#[allow(unused_macros)]
macro_rules! cfg_unix {
($($item:item)*) => {
$(
@ -116,6 +119,7 @@ macro_rules! cfg_unix {
/// Declares Windows-specific items.
#[doc(hidden)]
#[allow(unused_macros)]
macro_rules! cfg_windows {
($($item:item)*) => {
$(
@ -128,6 +132,7 @@ macro_rules! cfg_windows {
/// Declares items when the "docs" feature is enabled.
#[doc(hidden)]
#[allow(unused_macros)]
macro_rules! cfg_docs {
($($item:item)*) => {
$(
@ -139,6 +144,7 @@ macro_rules! cfg_docs {
/// Declares items when the "docs" feature is disabled.
#[doc(hidden)]
#[allow(unused_macros)]
macro_rules! cfg_not_docs {
($($item:item)*) => {
$(
@ -160,6 +166,18 @@ macro_rules! cfg_std {
}
}
/// Declares no-std items.
#[allow(unused_macros)]
#[doc(hidden)]
macro_rules! cfg_alloc {
($($item:item)*) => {
$(
#[cfg(feature = "alloc")]
$item
)*
}
}
/// Declares default items.
#[allow(unused_macros)]
#[doc(hidden)]
@ -180,6 +198,7 @@ macro_rules! cfg_default {
///
/// Inside invocations of this macro, we write a definitions that looks similar to the final
/// rendered docs, and the macro then generates all the boilerplate for us.
#[allow(unused_macros)]
#[doc(hidden)]
macro_rules! extension_trait {
(
@ -204,14 +223,14 @@ macro_rules! extension_trait {
#[allow(dead_code)]
mod owned {
#[doc(hidden)]
pub struct ImplFuture<T>(std::marker::PhantomData<T>);
pub struct ImplFuture<T>(core::marker::PhantomData<T>);
}
// A fake `impl Future` type that borrows its environment.
#[allow(dead_code)]
mod borrowed {
#[doc(hidden)]
pub struct ImplFuture<'a, T>(std::marker::PhantomData<&'a T>);
pub struct ImplFuture<'a, T>(core::marker::PhantomData<&'a T>);
}
// Render a fake trait combining the bodies of the base trait and the extension trait.

Loading…
Cancel
Save