Instantly share code, notes, and snippets.

@aturon /simplified.rs Secret
Created Jan 28, 2017

Embed
What would you like to do?
trait A {}
trait B {}
// The impl we want to allow to be added without breakage
impl<T: A> B for T {}
trait Assoc {
type Out;
}
impl<T> Assoc for T where T: A + B {
type Out = ();
}
impl<T> Foo for T where T: A, T: Assoc {}
// The `Out = ()` constraint here is basically a proxy for `T: A + B`
impl<T> Foo for T where T: A, T: Assoc, T: Assoc<Out = ()> {}
@lee-at-gusto

This comment has been minimized.

Show comment
Hide comment
@lee-at-gusto

lee-at-gusto Jan 28, 2017

This crate would be broken by impl line 5 regardless of impls line 15 and 18.

struct Foo;
impl A for Foo { }
impl Assoc for Foo {
    type Out = String;
}

lee-at-gusto commented Jan 28, 2017

This crate would be broken by impl line 5 regardless of impls line 15 and 18.

struct Foo;
impl A for Foo { }
impl Assoc for Foo {
    type Out = String;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment