Skip to main content

with_context

Macro with_context 

Source
macro_rules! with_context {
    ($($arg:tt)*) => { ... };
}
Expand description

Like format!, but for WithContext::with_context: builds a ContextSource that formats its message lazily, only if the result is actually an Err — .with_context(with_context!("failed at i={i}")) costs nothing on the success path, unlike .with_context(&format!(...)) (eagerly formats every time, even when nothing is wrong).