Skip to content

Re export macros from submodules #328

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ docs = ["broadcaster"]
unstable = ["broadcaster"]

[dependencies]
async-macros = "1.0.0"
# async-macros = "1.0.0"
async-macros = { path = "../async-macros"}
async-task = "1.0.0"
cfg-if = "0.1.9"
crossbeam-channel = "0.3.9"
Expand Down
8 changes: 4 additions & 4 deletions src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ pub use stdout::{stdout, Stdout};
pub use timeout::timeout;
pub use write::Write;

// For use in the print macros.
#[doc(hidden)]
pub use stdio::{_eprint, _print};
#[cfg(any(feature = "unstable", feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[doc(inline)]
pub use async_macros::{eprint, eprintln, print, println, write, writeln};

pub mod prelude;

Expand All @@ -59,6 +60,5 @@ mod repeat;
mod sink;
mod stderr;
mod stdin;
mod stdio;
mod stdout;
mod timeout;
21 changes: 0 additions & 21 deletions src/io/stdio.rs

This file was deleted.

5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ cfg_if! {
}
}

mod macros;
pub(crate) mod utils;

#[cfg(any(feature = "unstable", feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[doc(inline)]
pub use std::{write, writeln};
pub use async_macros::{eprint, eprintln, print, println, write, writeln};

pub use async_macros::task_local;
163 changes: 0 additions & 163 deletions src/macros.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub use crate::io::Write as _;
#[doc(no_inline)]
pub use crate::stream::Stream;
#[doc(no_inline)]
pub use crate::task_local;
pub use async_macros::task_local;

#[doc(hidden)]
pub use crate::io::buf_read::BufReadExt as _;
Expand Down
5 changes: 5 additions & 0 deletions src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ pub use std::task::{Context, Poll, Waker};
#[doc(inline)]
pub use async_macros::ready;

#[cfg(any(feature = "unstable", feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[doc(inline)]
pub use async_macros::task_local;

pub use block_on::block_on;
pub use builder::Builder;
pub use pool::spawn;
Expand Down
51 changes: 0 additions & 51 deletions src/task/task_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,6 @@ use super::worker;
use crate::future::Future;
use crate::utils::abort_on_panic;

/// Declares task-local values.
///
/// The macro wraps any number of static declarations and makes them task-local. Attributes and
/// visibility modifiers are allowed.
///
/// Each declared value is of the accessor type [`LocalKey`].
///
/// [`LocalKey`]: task/struct.LocalKey.html
///
/// # Examples
///
/// ```
/// #
/// use std::cell::Cell;
///
/// use async_std::task;
/// use async_std::prelude::*;
///
/// task_local! {
/// static VAL: Cell<u32> = Cell::new(5);
/// }
///
/// task::block_on(async {
/// let v = VAL.with(|c| c.get());
/// assert_eq!(v, 5);
/// });
/// ```
#[macro_export]
macro_rules! task_local {
() => ();

($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => (
$(#[$attr])* $vis static $name: $crate::task::LocalKey<$t> = {
#[inline]
fn __init() -> $t {
$init
}

$crate::task::LocalKey {
__init,
__key: ::std::sync::atomic::AtomicUsize::new(0),
}
};
);

($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
$crate::task_local!($(#[$attr])* $vis static $name: $t = $init);
$crate::task_local!($($rest)*);
);
}

/// The key for accessing a task-local value.
///
/// Every task-local value is lazily initialized on first access and destroyed when the task
Expand Down