This code in Rust gives an error:
trait Serialize {
const N: usize;
}
impl Serialize for u32 {
const N = 1;
}
fn main() {}
The error:
error: missing type for `const` item
--> src/main.rs:6:12
|
6 | const N = 1;
| ^ help: provide a type for the associated constant: `: usize`
I think for consistency with Rust we should also require a type for every associated constant.
In particular, for implementing #8548 we need to know the type of an associated constant before resolving its value or checking the associated constant on the related trait. Or, put another way, it simplifies some of the compiler logic.
This code in Rust gives an error:
The error:
I think for consistency with Rust we should also require a type for every associated constant.
In particular, for implementing #8548 we need to know the type of an associated constant before resolving its value or checking the associated constant on the related trait. Or, put another way, it simplifies some of the compiler logic.