Enhanced debugging and testing tools for Rust with better error messages and compile-time checks.
✨ Better Error Messages - Get colorful, detailed diffs instead of cryptic assertion failures
⚡ Compile-Time Safety - Catch bugs before your code even runs
🧠 Memory Layout Validation - Ensure your types have the expected size and alignment
🔧 Drop-in Replacement - Works with existing assert! macros but provides much more
Add to your Cargo.toml:
[dependencies]
diagnostics_tools = "0.11"use diagnostics_tools::*;
fn main()
{
// Instead of cryptic assertion failures, get beautiful diffs:
a_id!( vec![ 1, 2, 3 ], vec![ 1, 2, 4 ] );
// Outputs:
// assertion failed: `(left == right)`
//
// Diff < left / right > :
// [
// 1,
// 2,
// < 3,
// > 4,
// ]
}| Standard Rust | Diagnostics Tools | Advantage |
|---|---|---|
assert_eq!(a, b) |
a_id!(a, b) |
🎨 Colorful diff output |
assert!(condition) |
a_true!(condition) |
📝 Better error context |
| No compile-time checks | cta_true!(cfg(feature = "x")) |
⚡ Catch errors at compile time |
| No memory layout validation | cta_type_same_size!(u32, i32) |
🔍 Verify type assumptions |
a_true!(condition)/a_false!(condition)- Boolean checks with contexta_id!(left, right)/a_not_id!(left, right)- Value comparison with diffs- Debug variants (
a_dbg_*) that print values even on success
cta_true!(condition)- Validate conditions at compile time- Perfect for checking feature flags, configurations, or assumptions
cta_type_same_size!(TypeA, TypeB)- Ensure types have same sizecta_type_same_align!(TypeA, TypeB)- Check alignment requirementscta_ptr_same_size!(ptr1, ptr2)- Validate pointer sizescta_mem_same_size!(value1, value2)- Compare memory footprints
Explore our numbered examples to learn progressively:
001_basic_runtime_assertions.rs- Start here!002_better_error_messages.rs- See the difference003_compile_time_checks.rs- Prevent bugs early004_memory_layout_validation.rs- Low-level validation005_debug_variants.rs- Development helpers006_real_world_usage.rs- Practical scenarios
- 🧪 Testing: Get clearer test failure messages
- 🔧 Development: Debug complex data structures easily
- ⚙️ Systems Programming: Validate memory layout assumptions
- 📦 Library Development: Add compile-time safety checks
- 🚀 Performance Code: Ensure type sizes match expectations
- API Reference - Complete API documentation
TECHNICAL_DETAILS.md- Implementation detailsMIGRATION_GUIDE.md- Switching from standard assertionsFEATURES.md- Feature flags and configuration
Licensed under MIT license. See LICENSE for details.