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

Idea: impl chains ("else impls") for when other impls don't match #53953

Closed
Boscop opened this issue Sep 4, 2018 · 1 comment
Closed

Idea: impl chains ("else impls") for when other impls don't match #53953

Boscop opened this issue Sep 4, 2018 · 1 comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@Boscop
Copy link

Boscop commented Sep 4, 2018

A lot of the possible impl surface of a trait can't be impld in today's Rust because of the restrictions placed on impls.
I think it would be useful to have a way to express if THIS impl doesn't match, try THAT impl, in a chain, like in PureScript: purescript/purescript#2315

E.g. in Rust:

impl<.. /* some bounds */> Trait for Foo { ... }
else
impl<.. /* other bounds */> Trait for Foo { ... }
else
impl ...

It could even be possible to specify else impls for impls defined in dependency crates, if we can refer to them by a name.
That would require named impls, which there is already some demand for:

rust-lang/rfcs#2251

https://internals.rust-lang.org/t/looking-for-rfc-coauthors-on-named-impls/6275

@oli-obk
Copy link
Contributor

oli-obk commented Sep 4, 2018

This is a feature request to change the language and as such needs an RFC. I suggest you discuss this in the internals forum to figure out the caveats and then open an rfc

@oli-obk oli-obk closed this as completed Sep 4, 2018
@oli-obk oli-obk added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Sep 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

No branches or pull requests

2 participants