Advertisement
Guest User

Untitled

a guest
May 26th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. trait DoSomething {
  2. fn do_it() -> String {
  3. "hi".to_string()
  4. }
  5.  
  6. fn me_do_it(&self) -> String {
  7. let result = <Self as DoSomething>::do_it();
  8. format!("{}{}", result, "deho".to_string())
  9. }
  10. }
  11.  
  12. struct Foo;
  13.  
  14. impl DoSomething for Foo {}
  15.  
  16. fn main() {
  17. let output = Foo::do_it();
  18. println!("output: {}", output);
  19.  
  20. let foo = Foo;
  21. let output = foo.me_do_it();
  22. println!("output: {}", output);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement