Hello,
I am trying to write a generic struct which can store a dataset of variable size provided during compile time. I've encountered an error which I do not understand and would like to ask for your help.
struct DataSet<const N: usize>([u8; N]);
impl<const N: usize> DataSet<N> {
fn double_size(&self) > DataSet<{N*2}> {
let mut data_set = DataSet([0; N*2]);
for i in 0..N {
data_set.0[i] = self.0[i];
}
data_set
}
fn foo(&self, data_set: &DataSet<N>) {
let tmp = data_set.double_size();
}
}
I get the errormessage
error: unconstrained generic constant
> src/bin/main.rs:487:28

487  let tmp = data_set.double_size();
 ^^^^^^^^^^^

= help: try adding awhere
bound using this expression:where [(); {N*2}]: