For my fast & cheap inline strings
Stringlet v0.3.0 I just came up with a new solution. In hindsight it’s so obvious, I wonder why it’s not the standard way. Sadly rust-analyzer still greys it out, unlike #[cfg(test)], which it always treats as active:
#[cfg(doctest)]
mod doctests {
/**
```compile_fail
let _x: stringlet::Stringlet<65>;
```
*/
fn test_stringlet_65_compile_fail() {} // max SIZE 64 at compile time
}
Your take away is that you could work with #[cfg(any(test, doctest))].