-
-
Save yoshuawuyts/32a182677e907d37e38300090e2fcb6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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