Skip to content

Commit

Permalink
move macro from support
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed May 9, 2021
1 parent 2b881a7 commit 2904d74
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
6 changes: 5 additions & 1 deletion tokio/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ cfg_macros! {

// Includes re-exports needed to implement macros
#[doc(hidden)]
#[macro_use]
pub mod support;

// Macros used in doc tests.
#[doc(hidden)]
#[macro_use]
pub mod test;
28 changes: 0 additions & 28 deletions tokio/src/macros/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,3 @@ cfg_macros! {
pub use std::future::Future;
pub use std::pin::Pin;
pub use std::task::Poll;

/// Helper for writing a fallible unix-specific doctests.
#[macro_export]
macro_rules! doctest_unix {
($($body:tt)*) => {
#[cfg(unix)]
#[tokio::main]
async fn main() -> Result<(), Box<dyn ::std::error::Error>> {
$($body)*
}

#[cfg(not(unix))]
fn main() {}
}
}

/// Helper for writing a fallible windows-specific doctests.
#[macro_export]
macro_rules! doctest_windows {
($($body:tt)*) => {
#[cfg(windows)]
#[tokio::main]
async fn main() -> Result<(), Box<dyn ::std::error::Error>> { $($body)* }

#[cfg(not(windows))]
fn main() {}
}
}
25 changes: 25 additions & 0 deletions tokio/src/macros/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// Helper for writing a fallible unix-specific doctests.
#[macro_export]
macro_rules! doctest_unix {
($($body:tt)*) => {
#[cfg(unix)]
#[tokio::main]
async fn main() -> Result<(), Box<dyn ::std::error::Error>> { $($body)* }

#[cfg(not(unix))]
fn main() {}
}
}

/// Helper for writing a fallible windows-specific doctests.
#[macro_export]
macro_rules! doctest_windows {
($($body:tt)*) => {
#[cfg(windows)]
#[tokio::main]
async fn main() -> Result<(), Box<dyn ::std::error::Error>> { $($body)* }

#[cfg(not(windows))]
fn main() {}
}
}

0 comments on commit 2904d74

Please sign in to comment.