Enum tfe::Direction [−][src]
pub enum Direction { Left, Right, Up, Down, None, }
Enum that stores all available directions. This enum also provides some basic functions to allow a game to be using random moves.
Variants
Left
Right
Up
Down
None
Methods
impl Direction
[src]
impl Direction
pub fn sample() -> Direction
[src]
pub fn sample() -> Direction
Returns a random Direction
.
Examples
use tfe::Direction; let direction = Direction::sample(); // => Direction::Left
pub fn without(dirs: &Vec<Direction>) -> Vec<Direction>
[src]
pub fn without(dirs: &Vec<Direction>) -> Vec<Direction>
Returns a Vec<Direction>
excluding dirs: &Vec<Direction>
.
Examples
use tfe::Direction; let available = Direction::without(&vec![Direction::Left, Direction::Right]); assert_eq!(available, vec![Direction::Up, Direction::Down]);
pub fn sample_without(dirs: &Vec<Direction>) -> Direction
[src]
pub fn sample_without(dirs: &Vec<Direction>) -> Direction
Like tfe::Direction::sample
but combined with tfe::Direction::without
.
Returns a random Direction
after excluding dirs: &Vec<Direction>
.
Examples
use tfe::Direction; let direction = Direction::sample_without(&vec![Direction::Left, Direction::Right]); // => Direction::Up
Trait Implementations
impl Clone for Direction
[src]
impl Clone for Direction
fn clone(&self) -> Direction
[src]
fn clone(&self) -> Direction
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0
[src]Performs copy-assignment from source
. Read more
impl PartialEq for Direction
[src]
impl PartialEq for Direction
fn eq(&self, other: &Direction) -> bool
[src]
fn eq(&self, other: &Direction) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]This method tests for !=
.
impl Debug for Direction
[src]
impl Debug for Direction