Skip to content

Instantly share code, notes, and snippets.

@yoshuawuyts
Created March 19, 2018 10:15
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 yoshuawuyts/32a182677e907d37e38300090e2fcb6f to your computer and use it in GitHub Desktop.
Save yoshuawuyts/32a182677e907d37e38300090e2fcb6f to your computer and use it in GitHub Desktop.
struct bar;
impl Bar () {
new () -> Self {
Bar{}
}
}
impl Writer for Bar {
// this will only ever be called by the public-facing "write" method.
// the question is: what should we name this method? Right now the name conflicts
// with the public-facing API.
write (&self) {
}
}
trait Writer {
// this one is public facing
write (&self) {
println!("prepping write");
self.bar(); // calls the interal API
println!("done with write");
}
}
fn main () {
let bar = Bar::new()
bar.write() // calls the public API
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment