Advertisement
tyler569

Untitled

Feb 28th, 2017
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. trait Fooer {
  2. fn foo(&self) -> String;
  3. }
  4.  
  5. struct Foo;
  6.  
  7. impl Fooer for Foo {
  8. fn foo(&self) -> String {
  9. String::from_str("Hello World")
  10. }
  11. }
  12.  
  13. fn getfoo<T>(g: T) -> String
  14. where T: Fooer {
  15. g.foo()
  16. }
  17.  
  18. fn main() {
  19. let g = Foo;
  20. println!("{}", getfoo(g));
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement