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

GAT in Allocator Trait #1396

Closed
benjamin-lieser opened this issue May 20, 2024 · 3 comments
Closed

GAT in Allocator Trait #1396

benjamin-lieser opened this issue May 20, 2024 · 3 comments

Comments

@benjamin-lieser
Copy link

Now that GAT are stable in Rust, they could improve the Allocator Trait.

The T should be a GAT, which would remove a generic argument, and would allow the removal of a lot of trait bounds.

Now we have a lot of code like this:

impl<T: ComplexField, D> OMatrix<T, D, D>
where
    D: DimMin<D, Output = D>,
    DefaultAllocator: Allocator<T, D, D>
        + Allocator<(usize, usize), DimMinimum<D, D>>
        + Allocator<T, D>
        + Allocator<T::RealField, D>
        + Allocator<T::RealField, D, D>,

T can then be late bound when actually allocating.

I am not sure if I have overlooked something. There might be bad interactions for T : ?Sized

@sebcrozet
Copy link
Member

Thank you for the heads up! I made a PR with that change.

I didn’t realize that GAT were stabilized for arbitrary type parameters. I thought it was only for lifetimes type AssociatedType<'a>. Do you know what version of the compiler stabilized that for actual type parameters?

@benjamin-lieser
Copy link
Author

I am pretty sure they got stabilized together with the lifetimes in 1.65
It's definitely working with the current compiler: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=084a9df304548bbc6021da2fcce1c31a

@Andlon
Copy link
Collaborator

Andlon commented Jun 21, 2024

I believe this was resolved with #1397 being merged.

@Andlon Andlon closed this as completed Jun 21, 2024
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

3 participants