1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
pub struct Coord {
    pub x: usize,
    pub y: usize,
    pub hold: bool,
}

impl Coord {
    pub fn toggle(&mut self) {
        if self.hold {
            self.end()
        } else {
            self.hold()
        }
    }

    pub fn end(&mut self) {
        *self = Self::default()
    }

    pub fn hold(&mut self) {
        self.hold = true
    }
}