I have the following code so far:
const WORD_SIZE: usize = std::mem::size_of::<usize>() * 8;
pub struct Matrix<const M: usize, const N: usize> {
pub rows: [[usize; N]; M]
}
impl<const M: usize, const N: usize> Matrix<M, N> {
const N_words: usize = N * WORD_SIZE;
}
pub fn foo<const M: usize, const N: usize>(mat: &mut Matrix<{M}, {N}>) {
const a: usize = Matrix<M,N>::N_words;
}
I understand the line Matrix<M,N>::N_words
is incorrect. What is the correct syntax?
Edit: I changed my question after someone pointed out to use associated constants as seen here: https://doc.rust-lang.org/reference/items/generics.html#const-generics