1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
//! Minimal and simpler alternative to the futures crate.
//!
//! # Optional Features
//! Only the _`std`_ feature is enabled by default
//!
//! - Disable _`std`_ to use pasts without the standard library.
//! - Enable _`web`_ to use pasts within the javascript DOM.
//!
//! # Getting Started
//!
//! Add the following to your **`./Cargo.toml`**:
//! ```toml
//! [dependencies]
//! pasts = "0.14"
//!
//! ## This example uses async_main for convenience, but it is *not* required to
//! ## use pasts.
//! async_main = { version = "0.3", features = ["pasts"] }
//!
//! ## This example uses async-std for a sleep future, but async-std is *not*
//! ## required to use pasts.
//! async-std = "1.12"
//!
//! ## Also not required for pasts, but allows for portability with WebAssembly
//! ## in the browser.
//! [features]
//! web = ["async_main/web", "pasts/web"]
//! ```
//!
//! ## Multi-Tasking On Multiple Iterators of Futures
//! This example runs two timers in parallel using the `async-std` crate
//! counting from 0 to 6. The "one" task will always be run for count 6 and
//! stop the program, although which task will run for count 5 may be either
//! "one" or "two" because they trigger at the same time.
//!
//! ```rust,no_run
#![doc = include_str!("../examples/counter.rs")]
//! ```
#![cfg_attr(not(feature = "std"), no_std)]
#![doc(
html_logo_url = "https://ardaku.github.io/mm/logo.svg",
html_favicon_url = "https://ardaku.github.io/mm/icon.svg",
html_root_url = "https://docs.rs/pasts"
)]
#![forbid(unsafe_code)]
#![warn(
anonymous_parameters,
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
nonstandard_style,
rust_2018_idioms,
single_use_lifetimes,
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unused_extern_crates,
unused_qualifications,
variant_size_differences
)]
extern crate alloc;
pub mod notify;
mod r#loop;
mod spawn;
use self::prelude::*;
pub use self::{
r#loop::Loop,
spawn::{Executor, Park, Pool},
};
pub mod prelude {
//! Items that are almost always needed.
#[doc(no_inline)]
pub use alloc::boxed::Box;
#[doc(no_inline)]
pub use core::{
future::Future,
pin::Pin,
task::{
Context as Task,
Poll::{Pending, Ready},
},
};
#[doc(no_inline)]
pub use crate::notify::{
BoxNotify, Fuse, LocalBoxNotify, Notify, NotifyExt,
};
/// Indicates whether a value is available or if the current task has been
/// scheduled to receive a wakeup instead.
pub type Poll<T = ()> = core::task::Poll<T>;
}