diff --git a/Cargo.toml b/Cargo.toml index 7394d01..d5a1455 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,10 @@ ufmt-write = { path = "write", version = "0.1.0" } # NOTE do NOT turn `std` into a default feature; this is a no-std first crate std = ["ufmt-write/std"] +# When enabled, do_as_formatter() will be inlined. This can reduce code size +# for some applications. +inline = [] + [[test]] name = "vs-std-write" required-features = ["std"] diff --git a/src/lib.rs b/src/lib.rs index d74072e..11ee63c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -410,6 +410,7 @@ where { type Writer = W; + #[cfg_attr(feature = "inline", inline(always))] fn do_as_formatter( &mut self, f: impl FnOnce(&mut Formatter<'_, W>) -> Result<(), W::Error>, @@ -424,6 +425,7 @@ where { type Writer = W; + #[cfg_attr(feature = "inline", inline(always))] fn do_as_formatter( &mut self, f: impl FnOnce(&mut Formatter<'_, W>) -> Result<(), W::Error>,