Skip to main content

lazy_format

Macro lazy_format 

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

A macro that behaves like format! but constructs a diskann::utils::LazyString to enable deferred evaluation of the error message.

Invoking this macro has the following equivalence:

let a: f32 = 10.5;
let b: usize = 20;
// Macro form
let lazy_from_macro = lazy_format("This is a test. A = {}, B = {}", a, b);

// Direct form
let lazy_direct = crate::utils::LazyString::new(|f: &mut std::fmt::Formatter<'_>| {
    write!(f, "ihis is a test. A = {}, B = {}", a, b)
});