Skip to content

Support GAT's #4293

@philberty

Description

@philberty
trait Foo {
    type Bar<T>;
    
    fn foo<T>(self, value: T) -> Self::Bar<T>;
    fn baz<T>(self, value: T) -> Self::Bar<T>;
}

impl Foo for i32 {
    type Bar<T> = T;
    
    fn foo<T>(self, value: T) -> Self::Bar<T> {
        value
    }
    
    fn baz<T>(self, value: T) -> Self::Bar<T> {
        value
    }
}

fn main() {
   let a = 15; 
   
   let b = a.foo::<i8>(14i8);
   let c = a.baz::<u32>(32u32);
   
   dbg!(a, b, c);
}

From zulip @CohenArthur https://gcc-rust.zulipchat.com/#narrow/channel/281658-compiler-development/topic/GAT's/near/556945336

Metadata

Metadata

Assignees

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions