Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // use serde_derive; // 1.0.97
- use uuid; // 0.7.4
- pub struct MyItem {
- pub fld1: String,
- }
- pub struct ApprendoObject {
- pub item: MyItem,
- pub uuid: uuid::Uuid,
- }
- impl ApprendoObject {
- fn new() -> Self {
- let m: MyItem = MyItem {
- fld1: String::new(),
- };
- ApprendoObject {
- item: m,
- uuid: uuid::Uuid::new_v4(),
- }
- }
- }
- impl Iterator for ApprendoObject {
- type Item = MyItem;
- fn next(&mut self) -> Option<Self::Item> {
- Some(self.item)
- }
- }
- fn main() {
- let mut c = ApprendoObject::new();
- println!("{}", c.next().unwrap().fld1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement