pub enum Direction {
Left,
Right,
Up,
Down,
}
Enum that stores all available directions.
This enum also provides some basic functions to allow a game to be using random moves.
Returns a random Direction
.
use tfe::Direction;
let direction = Direction::sample();
Returns a Vec<Direction>
excluding dirs: &Vec<Direction>
.
use tfe::Direction;
let available = Direction::without(&vec![Direction::Left, Direction::Right]);
assert_eq!(available, vec![Direction::Up, Direction::Down]);
Like tfe::Direction::sample
but combined with tfe::Direction::without
.
Returns a Direction
after excluding dirs: &Vec<Direction>
.
use tfe::Direction;
let direction = Direction::sample_without(&vec![Direction::Left, Direction::Right]);
assert!(vec![Direction::Up, Direction::Down].contains(&direction));
let up = Direction::sample_without(&vec![Direction::Down, Direction::Left, Direction::Right]);
assert_eq!(Direction::Up, up);
Performs copy-assignment from source
. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Formats the value using the given formatter. Read more