Guest User

Untitled

a guest
Aug 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #[derive(Clone, Copy, Eq, PartialEq, Debug, Hash, PartialOrd)]
  2. pub struct Point(pub i16, pub i16);
  3.  
  4. static EMPTY: &[Point] = &[];
  5.  
  6. #[derive(Debug)]
  7. struct Bot1<'a> {
  8. path: Vec<Point>,
  9. cur_view: &'a [Point],
  10. }
  11.  
  12. impl<'a> Bot1<'a> {
  13. fn new() -> Self {
  14. let path = Vec::new();
  15. let b = Bot1 {
  16. path: path,
  17. cur_view: &EMPTY[..],
  18. };
  19. b
  20. }
  21. }
  22.  
  23. fn f1(_b: &mut Bot1) {}
  24. fn f2(_b: Bot1) {}
  25.  
  26. fn main() {
  27. let mut b = Bot1::new();
  28. b.path = vec![Point(0, 0), Point(0, 1), Point(0, 2)];
  29. b.cur_view = &b.path[1..];
  30.  
  31. println!("{:?}", &b);
  32.  
  33. let mut b1 = Bot1::new();
  34. b1.path = vec![Point(-1, -1), Point(0, 1), Point(6, 2)];
  35. b1.cur_view = &b1.path[2..];
  36.  
  37. println!("{:?}", &b1);
  38.  
  39. f1(&mut b1);
  40. f2(b1);
  41.  
  42. println!("{:?}", EMPTY);
  43. }
Add Comment
Please, Sign In to add comment