Guest User

Untitled

a guest
Jul 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #![allow(warnings)]
  2.  
  3. use std::fmt::Display;
  4.  
  5. struct MyStruct<T> where
  6. T: Display,
  7. //T: IntoIterator, adding this extra bound, requires changing the code below
  8. {
  9. my_field: T
  10. }
  11.  
  12. fn my_example(x: MyStruct<i32>)
  13. {
  14. println!("{}", x.my_field);
  15. }
  16.  
  17. fn main()
  18. {
  19. println!("Hello, world!");
  20.  
  21. my_example( MyStruct{ my_field: 42 } );
  22. }
Add Comment
Please, Sign In to add comment