Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Console {
- fn print_str(&mut self, text: &str);
- }
- trait ConsoleExt: Console {
- fn print<T: AsRef<str>>(&mut self, text: T) {
- self.print_str(text.as_ref())
- }
- }
- impl<T> ConsoleExt for T where T: ?Sized + Console {}
- struct RootConsole;
- impl Console for RootConsole {
- fn print_str(&mut self, text: &str) {
- unimplemented!()
- }
- }
- fn main() {
- let mut console = RootConsole;
- console.print("hello!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement