Guest User

Untitled

a guest
Jun 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. pub struct ClickTargetsLL {
  2. pub target: ClickTarget,
  3. pub next: Option<Box<ClickTargetsLL>>,
  4. }
  5.  
  6. pub enum ClickTarget {
  7. Gameboard,
  8. SaliencyMaps,
  9. RewardBars,
  10. }
  11.  
  12. pub struct ClickTargets {
  13. pub targets: Vec<ClickTarget>,
  14. }
  15.  
  16. impl From<ClickTargetsLL> for ClickTargets {
  17. fn from(tar: ClickTargetsLL) -> Self {
  18. let mut targets = Vec::new();
  19. targets.push(tar.target);
  20.  
  21. let mut next = tar.next;
  22.  
  23. while let Some(t) = next {
  24.  
  25. next = {
  26. let tt = *t;
  27. let ClickTargetsLL {
  28. target,
  29. next,
  30. } = tt;
  31.  
  32. targets.push(target);
  33. next
  34. };
  35. }
  36.  
  37. ClickTargets { targets }
  38. }
  39. }
  40.  
  41. fn main() {}
Add Comment
Please, Sign In to add comment