Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Clone, Copy, Eq, PartialEq, Debug, Hash, PartialOrd)]
- pub struct Point(pub i16, pub i16);
- static EMPTY: &[Point] = &[];
- #[derive(Debug)]
- struct Bot1<'a> {
- path: Vec<Point>,
- cur_view: &'a [Point],
- }
- impl<'a> Bot1<'a> {
- fn new() -> Self {
- let path = Vec::new();
- let b = Bot1 {
- path: path,
- cur_view: &EMPTY[..],
- };
- b
- }
- }
- fn f1(_b: &mut Bot1) {}
- fn f2(_b: Bot1) {}
- fn main() {
- let mut b = Bot1::new();
- b.path = vec![Point(0, 0), Point(0, 1), Point(0, 2)];
- b.cur_view = &b.path[1..];
- println!("{:?}", &b);
- let mut b1 = Bot1::new();
- b1.path = vec![Point(-1, -1), Point(0, 1), Point(6, 2)];
- b1.cur_view = &b1.path[2..];
- println!("{:?}", &b1);
- f1(&mut b1);
- f2(b1);
- println!("{:?}", EMPTY);
- }
Add Comment
Please, Sign In to add comment