| Crates.io | easy-macros-always-context |
| lib.rs | easy-macros-always-context |
| version | 1.0.1 |
| created_at | 2025-11-15 16:56:15.789462+00 |
| updated_at | 2025-11-17 06:20:09.643178+00 |
| description | Easy Macros support library |
| homepage | https://github.com/LimitLost/easy-macros |
| repository | https://github.com/LimitLost/easy-macros |
| max_upload_size | |
| id | 1934565 |
| size | 59,165 |
Use the parent crate instead.
#[always_context] attribute automatically adds .with_context(context!()) to all ? operators that don't already have context, eliminating the need to manually add context to every fallible operation.
use always_context::always_context;
use anyhow::Result;
#[always_context]
fn process_file(path: &str) -> Result<String> {
let content = std::fs::read_to_string(path)?; // Automatically gets context
let processed = content.trim().to_uppercase();
Ok(processed)
}
The #[always_context] attribute automatically transforms:
// From this:
let result = operation()?;
// To this:
let result = operation().with_context(context!("operation()"))?;
Context includes:
#[no_context] - Disable context generation entirely#[no_context_inputs] - Add context but exclude function arguments#[enable_context] - Re-enable context (useful in macros where it's auto-disabled)#[context(display)] - Use Display instead of Debug for argument formatting#[context(.method())] - Call method on argument before displaying#[context(tokens)] - Format as token stream (for proc-macro arguments)#[context(ignore)] - Exclude this argument from contextanyhow::Result<T> or Result<T, UserFriendlyError>? operators that don't already have context methodsThese expressions before ? require manual .with_context():
{ expr }?if ... {}?, match ... {}?, while ... {}?, for ... {}?, loop { ... }?obj.field?macro!()?easy-sql - Adds #[context(not_sql)] attribute for SQL macro integration