#[derive(DebugNoInline)]Expand description
Derive macro equivalent to #[derive(Debug)] but with #[inline(never)] on
the generated fmt implementation.
Rust’s built-in Debug derive emits #[inline] on fmt. For large or deeply
nested types — typically error enums formatted on fan-out paths — that lets
rustc inline the whole Debug tree into every {:?} / ?err call site,
which can bloat binary size. This derive preserves the exact Debug output;
it changes the inlining hint and, for large enums, the shape of the generated
body (see below).
Enums with at least CONCATENATED_NAMES_THRESHOLD variants additionally emit
one space-delimited name string and look variant names up by byte offset,
instead of one "<name>" literal per arm. This removes the per-arm string
literals and temporary locals that make derived Debug expensive to compile
and large in the binary; the output is still byte-identical to the built-in
derive. Data-carrying variants keep their normal debug_tuple/debug_struct
formatting, with the name passed in from the shared string.
Use it for large/nested types whose Debug is formatted in hot or fan-out
paths; keep #[derive(Debug)] for small, hot, leaf types. See
docs/development/rust-performance-principles.md, “Derived trait impls are
#[inline]”.
§Example
use vtcode_macros::DebugNoInline;
#[derive(DebugNoInline)]
pub struct Widgets {
foo: u32,
bar: usize,
}
assert_eq!(
format!("{:?}", Widgets { foo: 1, bar: 2 }),
"Widgets { foo: 1, bar: 2 }"
);