Skip to content

Allow type to create an alias for several trait bounds #8634

Closed
@huonw

Description

@huonw

e.g.

trait Foo {}
trait Bar {}


type Alias = Foo + Bar;

// typechecks fine:

fn bar<T: Foo + Bar>(t: T) {
    baz(t)
} 
fn baz<T: Alias>(t: T) {
    bar(t)
}

This is similar to defining a trait inheriting from both (trait Alias: Foo + Bar {}) but it's purely a synonym and doesn't have to be impl'd separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemA-type-systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions