Skip to content

Instantly share code, notes, and snippets.

@greyblake
Last active June 21, 2017 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greyblake/1c55be8537aea058ecbc1028ab88a5c7 to your computer and use it in GitHub Desktop.
Save greyblake/1c55be8537aea058ecbc1028ab88a5c7 to your computer and use it in GitHub Desktop.
trait A {
fn a(&self);
}
trait B {
fn b(&self);
}
trait C {
fn c(&self);
}
// Implement C for types, which implement A.
impl<T: A> C for T {
fn c(&self) {
self.a()
}
}
// NOTE: Fails to compile.
// Intention: implement trait C for the types, which implement B, but do not implement A.
impl<T: B + !A> C for T {
fn c(&self) {
self.b()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment