From f951625174881ca3fc7504e16b2ba46ededf4ed9 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 1 Dec 2020 09:50:57 +0900 Subject: [PATCH] Add `actix-reexport` feature --- actix-macros/CHANGES.md | 4 ++++ actix-macros/Cargo.toml | 5 ++++- actix-macros/src/lib.rs | 27 +++++++++++++++++++-------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/actix-macros/CHANGES.md b/actix-macros/CHANGES.md index 7b89882e..0893c57b 100644 --- a/actix-macros/CHANGES.md +++ b/actix-macros/CHANGES.md @@ -1,5 +1,9 @@ # CHANGES +## 0.1.3 - 2020-12-1 + +* Add `actix-reexport` feature + ## 0.1.2 - 2020-05-18 ### Changed diff --git a/actix-macros/Cargo.toml b/actix-macros/Cargo.toml index 3bef8ea2..1181ace5 100644 --- a/actix-macros/Cargo.toml +++ b/actix-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-macros" -version = "0.1.2" +version = "0.1.3" authors = ["Nikolay Kim "] description = "Actix runtime macros" repository = "https://github.com/actix/actix-net" @@ -16,6 +16,9 @@ proc-macro = true quote = "1.0.3" syn = { version = "^1", features = ["full"] } +[features] +actix-reexport = [] + [dev-dependencies] actix-rt = "1.0" diff --git a/actix-macros/src/lib.rs b/actix-macros/src/lib.rs index 04c374a5..e4baa15b 100644 --- a/actix-macros/src/lib.rs +++ b/actix-macros/src/lib.rs @@ -33,14 +33,25 @@ pub fn main(_: TokenStream, item: TokenStream) -> TokenStream { sig.asyncness = None; - (quote! { - #(#attrs)* - #vis #sig { - actix_rt::System::new(stringify!(#name)) - .block_on(async move { #body }) - } - }) - .into() + if cfg!(feature = "actix-reexport") { + (quote! { + #(#attrs)* + #vis #sig { + actix::System::new(stringify!(#name)) + .block_on(async move { #body }) + } + }) + .into() + } else { + (quote! { + #(#attrs)* + #vis #sig { + actix_rt::System::new(stringify!(#name)) + .block_on(async move { #body }) + } + }) + .into() + } } /// Marks async test function to be executed by actix runtime.