//@ build-pass #![allow(incomplete_features)] #![feature(generic_const_exprs)] use std::{marker::PhantomData, ops::Mul}; pub enum Nil {} pub struct Cons { _phantom: PhantomData<(T, L)>, } pub trait Indices { const RANK: usize; const NUM_ELEMS: usize; } impl Indices for Nil { const RANK: usize = 0; const NUM_ELEMS: usize = 1; } impl, const N: usize> Indices for Cons { const RANK: usize = I::RANK + 1; const NUM_ELEMS: usize = I::NUM_ELEMS * N; } pub trait Concat { type Output; } impl Concat for Nil { type Output = J; } impl Concat for Cons where I: Concat, { type Output = Cons>::Output>; } pub struct Tensor, const N: usize> where [u8; I::NUM_ELEMS]: Sized, { pub data: [u8; I::NUM_ELEMS], _phantom: PhantomData, } impl, J: Indices, const N: usize> Mul> for Tensor where I: Concat, >::Output: Indices, [u8; I::NUM_ELEMS]: Sized, [u8; J::NUM_ELEMS]: Sized, [u8; >::Output::NUM_ELEMS]: Sized, { type Output = Tensor<>::Output, N>; fn mul(self, _rhs: Tensor) -> Self::Output { Tensor { data: [0u8; >::Output::NUM_ELEMS], _phantom: PhantomData, } } } fn main() {}