Available on crate feature
dhat-compat only.Expand description
dhat-rs-shaped compatibility surface.
Behind the dhat-compat cargo feature. Provides drop-in
replacements for dhat::Alloc, dhat::Profiler,
dhat::ProfilerBuilder, dhat::HeapStats, dhat::AdHocStats,
and dhat::ad_hoc_event so consumers migrating from dhat-rs
can swap allocator profilers with a one-line import change:
use mod_alloc::dhat_compat as dhat;
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;
fn main() {
let _profiler = dhat::Profiler::new_heap();
// ... work ...
// _profiler drops here → writes dhat-heap.json
}§Differences from dhat-rs
Documented in MIGRATING_FROM_DHAT.md. Summary:
- Backtrace depth is capped at 8 frames (Tier 2 walker limit);
ProfilerBuilder::trim_backtracesis accepted for parity but silently clamps. - Drop-time file-write errors are swallowed silently — same as dhat-rs’s behaviour.
- Double-Profiler construction is a no-op rather than a panic (dhat-rs panics). Last writer wins on the JSON file.
dhat::assert!/assert_eq!/assert_ne!macros are not yet shipped. UseHeapStats::get()directly in test assertions.
Structs§
- AdHoc
Stats - Ad-hoc-mode statistics snapshot. Mirrors
dhat::AdHocStats. - Alloc
- Drop-in replacement for
dhat::Alloc. - Heap
Stats - Heap-mode statistics snapshot. Mirrors the shape of
dhat::HeapStatsfield-for-field so consumers migrating from dhat can drop in the type alias without code edits. - Profiler
- RAII handle that writes a DHAT-format JSON report on drop.
- Profiler
Builder - Builder for
Profiler.
Enums§
- Mode
- Profiler mode — heap-allocation tracking or ad-hoc event
counting. Pick at construction via
Profiler::new_heap/Profiler::new_ad_hocor viaProfilerBuilder.
Functions§
- ad_
hoc_ event - Record one ad-hoc event with the given weight.