Skip to content

Implement multiple traits at once #1281

@nrc

Description

@nrc

A little bit of syntax sugar to make working with trait hierarchies easier.

Probably best to restrict to super-/sub-traits. E.g.,

trait Foo {
    fn foo(&self) -> usize;
}

trait Bar: Foo {
    fn bar1(&mut self) -> String;
    fn bar2(&self) -> Foo;
}

impl Foo + Bar for SomeConcreteType {
    fn foo(&self) -> usize{
        ...
    }

    fn bar1(&mut self) -> String{
        ...
    }

    fn bar2(&self) -> Foo {
        ...
    }    
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions