External Publication
Visit Post

Sized (or Sizeable) str, e.g. str<const N: usize>

Rust Internals [Unofficial] April 30, 2026
Source

daniel-pfeiffer:

In a nutshell, that’s the base case of my stringlet!() macro, yes. But I get a feeling that many people don’t like macros. Some crates even hide them in an optional feature.

The common reason why procedural macros are often an optional feature is that they can have significant extra cost to compile the macro crate and its dependencies. macro_rules macros have no comparable cost, so you will generally not find macro_rules macros gated by features.

I’m against macro overuse myself, but “this can’t be done without a macro except by counting bytes“ is a good reason to use a macro; and in my opinion, all you need to do is offer some non-macro way to do whatever the task is, and the fn strict_from_ref() in my example code or @CAD97’s new() does that.

Discussion in the ATmosphere

Loading comments...