Skip to content

Instantly share code, notes, and snippets.

@Leopard2A5
Created February 8, 2017 20:42
Show Gist options
  • Select an option

  • Save Leopard2A5/6c92ca3abb4ed643669d6fc7bd16196b to your computer and use it in GitHub Desktop.

Select an option

Save Leopard2A5/6c92ca3abb4ed643669d6fc7bd16196b to your computer and use it in GitHub Desktop.
use schema::games;
#[derive(Debug, Copy, Clone, PartialEq)]
enum Player {
P1,
P2,
}
#[derive(Queryable)]
struct Game {
pub id: i32,
pub current_player: Player,
}
#[derive(Insertable)]
#[table_name="games"]
struct NewGame {
pub current_player: Player,
}
impl NewGame {
fn new() -> NewGame {
NewGame {
current_player: Player::P1,
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment