Skip to content

Allow trait methods to return impl Trait types. #65481

Closed

Description

@kevincox

It should be possible for methods in traits to have a return value specified as impl Trait. This would allow traits to return values without having to specify the exact type or wrap in indirection.

This would obviously not be object-safe as the size of the return value would not be known.

Activity

  1. jonas-schievink commented on Oct 16, 2019

    @jonas-schievink
    Contributor

    Please refer to https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md#limitation-to-freeinherent-functions for why this isn't allowed. Doing this requires substantial language design efforts and an RFC, so closing in favor of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions