Guest User

Untitled

a guest
Feb 18th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. trait HasS {
  2. fn get_s(&self) -> String;
  3. }
  4.  
  5. struct Foo {}
  6.  
  7. impl HasS for Foo {
  8. fn get_s(&self) -> String {
  9. String::from("Foo")
  10. }
  11. }
  12.  
  13. impl HasS for &Foo {
  14. fn get_s(&self) -> String {
  15. String::from("*Foo")
  16. }
  17. }
  18.  
  19. fn main() {
  20. let foo = Foo{};
  21. println!("{}", foo.get_s());
  22. println!("{}", (&&foo).get_s());
  23. }
Add Comment
Please, Sign In to add comment