Guest User

Untitled

a guest
Dec 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. use std::fmt::Display;
  2.  
  3. trait Show {
  4. fn show(&self) -> String;
  5. }
  6.  
  7. impl<T: Display> Show for T {
  8. fn show(&self) -> String {
  9. format!("{}", &self)
  10. }
  11. }
  12.  
  13. fn blah_vtable<F>(f: F, x: i32, y: bool, z: char) -> String
  14. where
  15. F: Fn(&dyn Show) -> String,
  16. {
  17. format!("{} {} {}", f(&x), f(&y), f(&z))
  18. }
  19.  
  20. fn main() {
  21. println!("Hello, world!");
  22. }
Add Comment
Please, Sign In to add comment