4 ms·
Really looking forward to const generics becoming more and more useful in the future! A current limitation I hit yesterday is that you can't use a (non-literal)
by dthul 5y ago
Really looking forward to const generics becoming more and more useful in the future! A current limitation I hit yesterday is that you can't use a (non-literal) expression as a const generic parameter yet. I wanted to specify 32KiB as "32 * 1024" but had to write "32768" instead.
- nynx 5y agoYou can use constant expressions in const generics in many cases. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1c1073976ef2fda5fcd4be32cea49e92 https://play.rust-lang.org/?version=stable&mode=debug&editio...
- dthul 5y agoThanks! I didn't realize that it required curly braces and only went off of the red squiggly line my IDE put there instead of reading the helpful compiler output.
- rhn_mk1 5y agoI'm always hitting the limitation that I can't use a const parameter on a trait like a const generic. As an example, this is disallowed: struct Helper<B: Buffer> { x: [u8; B::SIZE], }