carbotaniuman / auto_ops

Macros for overloading operators easily in Rust.
MIT License
34 stars 9 forks source link

Is there a way to support generics? #2

Open flajann2 opened 4 years ago

flajann2 commented 4 years ago

I would like to do something like:

impl_op!<I> (& |a: &BitSparseArray<I>, b: &BitSparseArray<I>| -> BitSparseArray<I> {...} But currently there appears no way to do that. Would you like to add that functionality? Or maybe I can and generate a pull request?

Thanks.

FelixSelter commented 1 year ago

Also const generics support would be great.

impl<const ROWS: usize, const COLS: usize, const OTHERCOLS: usize>
    std::ops::Mul<&Matrix<COLS, OTHERCOLS>> for &Matrix<ROWS, COLS>
where
    [(); ROWS * COLS]:,
    [(); COLS * OTHERCOLS]:,
    [(); ROWS * OTHERCOLS]:,
{
    type Output = Matrix<ROWS, OTHERCOLS>;