What’s where [(); SIZE + Kind::EXTRA]:?
I had removed most generic bounds on stringlet, as I found they infect every generic caller. But now the compiler is forcing me back to square one:
I’m trying to clean up VarStringlet’s messy extra len-byte, by moving it into the byte array. Having stumbled over how fixedstr::strN takes away one from the requested size, I want an additional byte, to avoid such surprises.
I understand const generic operations and picking up an associated const from a generic type require nightly and #![feature(generic_const_exprs)]. But then I get this, not only on the type itself, but also on every user:
error: unconstrained generic constant
--> /home/pfeiffer/dp/Rust/stringlet/src/lib.rs:178:21
|
178 | pub(crate) str: [u8; SIZE + Kind::EXTRA],
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try adding a `where` bound
|
176 | > where [(); SIZE + Kind::EXTRA]: {
| +++++++++++++++++++++++++++++++
error: unconstrained generic constant
--> /home/pfeiffer/dp/Rust/stringlet/src/cmp.rs:21:49
|
21 | (true, ..) => SIZE == 0 || self.str == other.str[..],
| ^^
|
help: try adding a `where` bound
|
14 | fn eq(&self, other: &self2!()) -> bool where [(); SIZE + Kind::EXTRA]: {
| +++++++++++++++++++++++++++++++
Besides suggesting the wrong inner type () vs. u8, that burden makes this feature unergonomic. So I wonder and hope: is this temporary, until some prerequisite gets implemented?
Discussion in the ATmosphere