nalgebra icon indicating copy to clipboard operation
nalgebra copied to clipboard

`Dyn` could have `DimName` implemented upstream

Open YeungOnion opened this issue 1 year ago • 0 comments

I'd like to be able to do something to support both static and dynamic allocation on one generic type like below,

impl ::rand::distributions::Distribution<DVector<f64> for Mut<Dyn> {
    fn sample(...) -> DVector<f64> { ... }
}
impl<D> ::rand::distributions::Distribution<OVector<f64, D>> for Dirichlet<D>
where
    D: Dim + DimName,
    nalgebra::DefaultAllocator: nalgebra::allocator::Allocator<f64, D>,
{
    fn sample(...) -> OVector<f64, D> { ... }
}

but the interface has a problem the second impl could duplicate the first if Dyn implements DimName upstream.

Am I going about this the wrong way, or can I request to seal the DimName trait against being implemented on other structs?

YeungOnion avatar Aug 03 '24 04:08 YeungOnion