Summary
Across three lessons we introduced core hooq usage.
There are further mechanisms and details not covered in the tutorial; consult the individual reference pages for deeper exploration.
- Reference: Detailed explanations of each feature.
- Recipes & Ideas: Usage examples of built‑in flavors, exploratory scenarios, and hidden tricks.
Comparison With Other Approaches
Applying #[hooq] (or #[hooq(anyhow)]) to every function yields a pseudo stack trace for errors. Here is a comparison with other strategies for obtaining stack‑like traces:
Backtrace | tracing | hooq | |
|---|---|---|---|
| Learning cost / flexibility | ⚠️ | ⚠️ | 🌈 |
| Ease of type definitions | ⚠️ | ✅ | ✅ |
| Macro‑less | 🌈 | ❌ | ❌ |
| Information volume control | ⚠️ | ✅ | 🌈 |
| Platform support | ⚠️ | ✅ | 🌈 |
Legend:
- 🌈: Excellent
- ✅: Good
- ⚠️: So‑so
- ❌: Poor
Explanation:
- Learning cost / flexibility
- ⚠️
Backtracerequires settingRUST_LIB_BACKTRACE=1and relies on OS thread info; extra system knowledge helps. - ⚠️
tracingis powerful but may be overkill if you only want a stack trace analogue. - 🌈
hooqrequires only adding an attribute on functions.
- ⚠️
- Ease of type definitions
- ⚠️ With
thiserror+Backtrace, you must pre‑plan fields; retrofitting is harder as error types multiply. - ✅
tracingimposes no such constraints. - ✅
hooqcooperates with arbitrary error crates.
- ⚠️ With
- Macro‑less
- 🌈
Backtraceneeds no macros. - ❌
tracinggenerally needs#[tracing::instrument]for effortless spans. - ❌
hooqis an attribute macro by design.
- 🌈
- Information volume control
- ⚠️ Raw
Backtraceoutput is often too verbose (and weak for async); pairing withcolor-eyrehelps. - ✅
tracinggives structured spans; precise line of each?still requires manual logging. - 🌈
hooqpinpoints only annotated functions and the exact?/return/ tail expression locations.- Conditional usage via
#[cfg_attr(..., hooq(...))]enables feature/test scoped tracing. - 💡 Combine with
tracingto augment granularity—see tracing flavor.
- Conditional usage via
- ⚠️ Raw
- Platform support
- ⚠️
Backtracehas platform caveats (see official docs ). - ✅ Standard logging with
tracingis widely portable. - 🌈 hooq merely inserts methods; no platform primitives required.
- 💡
#[hooq::method(.unwrap()!)]can alias?to.unwrap()behind a feature.
- 💡
- ⚠️