1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
pub use self::position::Position;

mod position {

    #[derive(Debug, PartialEq)]
    pub enum Position {
        Top,
        Left,
        Right,
        Bottom,
        TopLeft,
        TopRight,
        BottomLeft,
        BottomRight,
        Middle,
    }

    impl Position {
        pub fn top(&self) -> bool {
            match *self {
                Position::TopLeft => true,
                Position::Top => true,
                Position::TopRight => true,
                _ => false,
            }
        }
        pub fn left(&self) -> bool {
            match *self {
                Position::TopLeft => true,
                Position::Left => true,
                Position::BottomLeft => true,
                _ => false,
            }
        }
        pub fn right(&self) -> bool {
            match *self {
                Position::TopRight => true,
                Position::Right => true,
                Position::BottomRight => true,
                _ => false,
            }
        }
        pub fn bottom(&self) -> bool {
            match *self {
                Position::BottomLeft => true,
                Position::Bottom => true,
                Position::BottomRight => true,
                _ => false,
            }
        }
    }
}