Module camel

Source
Expand description

The camel module models Camel Up.

It identifies all the relevant parts of the Camel Up game. Starting from a Race it allows you to perform a Roll, which will return the resulting race.

let race = Race::from(vec![Marker::Camel(Camel::Red), Marker::Divider, Marker::Camel(Camel::Yellow)]);
let roll = Roll::from((Camel::Red, Face::One));

let actual = race.perform(roll);

let expected = Race::from(vec![Marker::Camel(Camel::Yellow), Marker::Camel(Camel::Red)]);
assert_eq!(actual, expected);

One can cut down on the verbosity by using the various parse functions and other convenience functions. The above code example can be widdled down to

let race = "r,y".parse::<Race>().expect("to parse");

let actual = race.perform((Camel::Red, Face::One));

let expected = "yr".parse::<Race>().expect("to parse");
assert_eq!(actual, expected);

Structs§

Dice
Represents the dice that still can be rolled.
Race
Models a race as a sequence of markers.
Roll
A roll of the dice

Enums§

Camel
The various camels that race in the game.
Face
The faces of the Camel dice.
Marker
A marker is used to describe a race.
NoDice
When parsing of Dice goes wrong, this enumeration tells you precisely what went down.
NotAMarker
When parsing of Marker goes wrong, this enumeration tells you precisely what went down.
RaceParseError
When parsing of Race goes wrong, this enumeration tells you precisely what went down.