Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. // use serde_derive; // 1.0.97
  2. use uuid; // 0.7.4
  3.  
  4. pub struct MyItem {
  5. pub fld1: String,
  6. }
  7.  
  8. pub struct ApprendoObject {
  9. pub item: MyItem,
  10. pub uuid: uuid::Uuid,
  11. }
  12.  
  13. impl ApprendoObject {
  14. fn new() -> Self {
  15. let m: MyItem = MyItem {
  16. fld1: String::new(),
  17. };
  18. ApprendoObject {
  19. item: m,
  20. uuid: uuid::Uuid::new_v4(),
  21. }
  22. }
  23. }
  24.  
  25. impl Iterator for ApprendoObject {
  26. type Item = MyItem;
  27. fn next(&mut self) -> Option<Self::Item> {
  28. Some(self.item)
  29. }
  30. }
  31.  
  32. fn main() {
  33. let mut c = ApprendoObject::new();
  34. println!("{}", c.next().unwrap().fld1);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement