af_proc_macros/
lib.rs

1// Copyright © 2020 Alexandra Frydl
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7mod attr_future_boxed;
8mod attr_main;
9mod attr_test_main;
10mod prelude;
11
12/// Modifies an `async` function to return a `Box<dyn Future + Send>`.
13#[proc_macro_attribute]
14pub fn future_boxed(
15  _: proc_macro::TokenStream,
16  item: proc_macro::TokenStream,
17) -> proc_macro::TokenStream {
18  attr_future_boxed::run(item, true)
19}
20
21/// Modifies an `async` function to return a `Box<dyn Future>`.
22#[proc_macro_attribute]
23pub fn future_boxed_local(
24  _: proc_macro::TokenStream,
25  item: proc_macro::TokenStream,
26) -> proc_macro::TokenStream {
27  attr_future_boxed::run(item, false)
28}
29
30/// Defines an async main function for an `af-core` application.
31#[proc_macro_attribute]
32pub fn main(_: proc_macro::TokenStream, item: proc_macro::TokenStream) -> proc_macro::TokenStream {
33  attr_main::run(item)
34}
35
36/// Defines a main function for an `af_core::test` suite.
37#[proc_macro_attribute]
38pub fn test_main(
39  _: proc_macro::TokenStream,
40  item: proc_macro::TokenStream,
41) -> proc_macro::TokenStream {
42  attr_test_main::run(item)
43}