Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dyn could have DimName implemented upstream #1431

Open
YeungOnion opened this issue Aug 3, 2024 · 0 comments
Open

Dyn could have DimName implemented upstream #1431

YeungOnion opened this issue Aug 3, 2024 · 0 comments

Comments

@YeungOnion
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant