pub fn eat(&mut self) {
        match self.direction {
            Direction::Left => {
                self.tail.push_back(Position {
                    x: self.position.x + 1,
                    y: self.position.y,
                });
            }
            Direction::Right => {
                self.tail.push_back(Position {
                    x: self.position.x - 1,
                    y: self.position.y,
                });
            }
            Direction::Up => {
                self.tail.push_back(Position {
                    x: self.position.x,
                    y: self.position.y + 1,
                });
            }
            Direction::Down => {
                self.tail.push_back(Position {
                    x: self.position.x,
                    y: self.position.y - 1,
                });
            }
            Direction::Still => {}
        }
        self.length += 1;
    }
// have the snake eat food updating the snakes length
have the snake eat food updating the snakes length
have the snake eat food updating the snakes length
pub fn eat(&mut self) {
        match self.direction {
            Direction::Left => {
                self.tail.push_back(Position {
                    x: self.position.x + 1,
                    y: self.position.y,
                });
            }
            Direction::Right => {
                self.tail.push_back(Position {
                    x: self.position.x - 1,
                    y: self.position.y,
                });
            }
            Direction::Up => {
                self.tail.push_back(Position {
                    x: self.position.x,
                    y: self.position.y + 1,
                });
            }
            Direction::Down => {
                self.tail.push_back(Position {
                    x: self.position.x,
                    y: self.position.y - 1,
                });
            }
            Direction::Still => {}
        }
        self.length += 1;
    }
pub fn eat ( & mut self ) { match self . direction { Direction :: Left => { self . tail . push_back ( Position { x : self . position . x + 1 , y : self . position . y , } ) ; } Direction :: Right => { self . tail . push_back ( Position { x : self . position . x - 1 , y : self . position . y , } ) ; } Direction :: Up => { self . tail . push_back ( Position { x : self . position . x , y : self . position . y + 1 , } ) ; } Direction :: Down => { self . tail . push_back ( Position { x : self . position . x , y : self . position . y - 1 , } ) ; } Direction :: Still => { } } self . length += 1 ; }
have the snake eat food updating the snakes length
have the snake eat food updating the snakes length
&mut self
&mut self