From 68a652ed2f51d366bb8033497e6dfe545895410e Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Thu, 23 Jul 2026 08:08:33 +0800 Subject: feat: scaffold crate structure and implement core macros Add the project skeleton, LICENSE files, README, Makefile, doc examples, and the initial implementation of `#[func]`, `invoke!`, and `select!` procedural macros. --- src/lib.rs | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/lib.rs (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..d6a3c37 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,105 @@ +#![doc = include_str!("../doc/lib.md")] +#![deny(missing_docs)] + +use proc_macro::TokenStream; + +pub(crate) mod config; +pub(crate) mod func; +pub(crate) mod invoke; +pub(crate) mod select; + +pub(crate) use proc_macro2::TokenStream as TokenStream2; +pub(crate) use syn::Result as SynResult; + +#[doc = include_str!("../doc/func.md")] +/// +/// # How to use? +/// +/// ``` +/// # use might_be_async::*; +#[doc = include_str!("../doc/usage/func.rs")] +/// ``` +/// +/// # Expanded +/// +/// The above code will be expanded into the following: +/// +/// Sync: +/// +/// ``` +/// # use might_be_async::*; +#[doc = include_str!("../doc/usage/func_expand.rs")] +/// ``` +/// +/// Async: +/// +/// ``` +/// # use might_be_async::*; +#[doc = include_str!("../doc/usage/func_async_expand.rs")] +/// ``` +#[proc_macro_attribute] +pub fn func(attr: TokenStream, item: TokenStream) -> TokenStream { + func::func(attr, item) +} + +#[doc = include_str!("../doc/invoke.md")] +/// +/// # How to use? +/// +/// ``` +/// # use might_be_async::*; +#[doc = include_str!("../doc/usage/invoke.rs")] +/// ``` +/// +/// # Expanded +/// +/// The above code will be expanded into the following: +/// +/// Sync: +/// +/// ``` +/// # use might_be_async::*; +#[doc = include_str!("../doc/usage/invoke_expand.rs")] +/// ``` +/// +/// Async: +/// +/// ``` +/// # use might_be_async::*; +#[doc = include_str!("../doc/usage/invoke_async_expand.rs")] +/// ``` +#[proc_macro] +pub fn invoke(input: TokenStream) -> TokenStream { + invoke::invoke(input) +} + +#[doc = include_str!("../doc/select.md")] +/// +/// # How to use? +/// +/// ``` +/// # use might_be_async::*; +#[doc = include_str!("../doc/usage/select.rs")] +/// ``` +/// +/// # Expanded +/// +/// The above code will be expanded into the following: +/// +/// Sync: +/// +/// ``` +/// # use might_be_async::*; +#[doc = include_str!("../doc/usage/select_expand.rs")] +/// ``` +/// +/// Async: +/// +/// ``` +/// # use might_be_async::*; +#[doc = include_str!("../doc/usage/select_async_expand.rs")] +/// ``` +#[proc_macro] +pub fn select(input: TokenStream) -> TokenStream { + select::select(input) +} -- cgit