Skip to content

Instantly share code, notes, and snippets.

@comex
Created December 6, 2019 23:32
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 comex/ee809f4bdeec5c6cf7b1751ee1642193 to your computer and use it in GitHub Desktop.
Save comex/ee809f4bdeec5c6cf7b1751ee1642193 to your computer and use it in GitHub Desktop.
mod private {
pub trait Super {
fn foo(self);
}
pub trait Child: Super {}
impl Super for u32 {
fn foo(self) {}
}
impl Child for u32 {}
}
use private::Child;
fn huh<T: Child>(x: T) {
x.foo(); // OK
}
fn hah(x: u32) {
huh(x); // OK
x.foo(); // error: no method named `foo` found
// for type `u32` in the current scope
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment