error: generic parameters may not be used in const operations
--> src/lib.rs:4:43
|
4 | arr: [Key; 1024 / std::mem::size_of::<Key>()]
| ^^^ cannot perform const operation using `Key`
|
= note: type parameters may not be used in const expressions
type SomeKey = u64;
// This does not work
struct NotWorking<Key: Sized> {
arr: [Key; 1024 / std::mem::size_of::<Key>()]
}
struct Working {
arr: [SomeKey; 1024 / std::mem::size_of::<SomeKey>()]
}
#![feature(generic_const_exprs)]
struct NotWorking<Key>
where
// this where clause is required to constrain the generic, once GCEs
// are complete it's need might go away.
[(); 1024 / std::mem::size_of::<Key>()]:,
{
arr: [Key; 1024 / std::mem::size_of::<Key>()],
}