aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-23 08:08:33 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-23 14:01:45 +0800
commit68a652ed2f51d366bb8033497e6dfe545895410e (patch)
treed463833846248410733e196a0939c59cd67ca8a2 /src/lib.rs
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.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs105
1 files changed, 105 insertions, 0 deletions
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)
+}