easy_macros/
lib.rs

1#[cfg(feature = "all-syntax-cases")]
2pub use all_syntax_cases::*;
3
4#[cfg(feature = "always-context")]
5pub use always_context::*;
6
7#[cfg(feature = "build")]
8pub use always_context_build;
9
10#[cfg(feature = "anyhow-result")]
11/// Enables procedural macros to return `anyhow::Result<TokenStream>` for ergonomic error handling.
12///
13/// This attribute wraps proc-macro functions to automatically handle `anyhow::Result` return types,
14/// converting errors into appropriate `compile_error!` tokens.
15///
16/// # Usage
17///
18/// ```rust,ignore
19/// use anyhow::Context;
20/// use proc_macro::TokenStream;
21///
22/// #[proc_macro]
23/// #[anyhow_result]
24/// pub fn my_macro(input: TokenStream) -> anyhow::Result<TokenStream> {
25///     let parsed: syn::ItemStruct = syn::parse(input)
26///         .context("Expected a struct definition")?;
27///     
28///     // Your macro logic here
29///     Ok(quote! { /* generated code */ }.into())
30/// }
31/// ```
32///
33/// # Error Handling
34///
35/// When your function returns an `Err`, `anyhow_result` automatically converts it:
36/// - **`#[proc_macro]` and `#[proc_macro_derive]`**: Returns `compile_error!` with the error message
37/// - **`#[proc_macro_attribute]`**: Returns `compile_error!` followed by the original input item
38///
39/// # See Also
40///
41/// - [`anyhow`](https://docs.rs/anyhow/) - Error handling library
42/// - [`syn`](https://docs.rs/syn/) - Rust code parsing  
43/// - [`quote`](https://docs.rs/quote/) - Code generation
44pub use anyhow_result::anyhow_result;
45
46#[cfg(feature = "attributes")]
47pub use attributes::*;
48
49// === Helper Function Exports ===
50
51/// Helper utilities for building procedural macros
52#[cfg(feature = "helpers-dont-use-directly-this-feature")]
53pub use helpers::*;
54
55#[cfg(test)]
56mod macro_tests;