Easy Macros
Use the parent crate instead.
What is this?
Easy Macros Helpers is a collection of utility functions provided and used by the Easy Macros crate
Core Features
Error Context Generation
context!- Generate context strings for error handling with automatic file/line information
Token Stream Management
TokensBuilder- Accumulate and combine token streams with methods insidereadable_token_stream- Format token strings for better readabilitytoken_stream_to_consistent_string- Normalize token representation across contexts
Error Handling
parse_macro_input!- Enhanced version of syn's macro that returnsOk(TokenStream)on parse errors (instead ofTokenStream)expr_error_wrapwithCompileErrorProvidertrait - Wrap expressions with compile-time error reporting
Code Generation Utilities
indexed_name- Generate indexed identifiers (field0,field1, etc.)find_crate- Locate crate references for generated code (supports renaming)find_crate_list- Try multiple crates, return first found
Examples
Using context! for Error Handling
use fs;
let result = load_config;
assert!;
let error_msg = format!;
assert!;
Using TokensBuilder for Token Accumulation
let mut result = default;
// Add multiple token streams
result.add;
result.add;
// Wrap everything in braces
result.braced;
// Get final result
let tokens = result.finalize;
assert_eq!;
Support for Result<TokenStream, ...> with parse_macro_input!
Generating Indexed Names
let field_names = indexed_name;
let output = quote! ;
assert_eq!;
Error Wrapping for Better Diagnostics
let mut errors = Vec::new;
let mut expr = parse_quote!;
// Add some errors
errors.push;
errors.push;
// Wrap expression with compile errors
expr_error_wrap;
assert_eq!;
Finding Crate References (with Renaming Support)
if let Some = find_crate
// Handles renamed crates automatically
// If Cargo.toml has: serde_renamed = { package = "serde", version = "1.0" }
// The above will return: serde_renamed::Serialize
// Try multiple crates with fallbacks
let async_crates = &;
if let Some = find_crate_list