Skip to content

Instantly share code, notes, and snippets.

@radix
Last active January 6, 2017 21:54
Show Gist options
  • Save radix/bea119390be3be7b776b83bc1079c819 to your computer and use it in GitHub Desktop.
Save radix/bea119390be3be7b776b83bc1079c819 to your computer and use it in GitHub Desktop.
impl<A> Creature<A> {
pub fn into_vari(self) -> CreatureVari {
if self.can_act() {
CreatureVari::Able(Creature::<Able> {
name: self.name,
pos: self.pos,
conditions: self.conditions,
abilities: self.abilities,
cur_energy: self.cur_energy,
cur_health: self.cur_health,
max_energy: self.max_energy,
max_health: self.max_health,
_p: PhantomData,
})
} else {
CreatureVari::Incap(Creature::<Incap> {
name: self.name,
pos: self.pos,
conditions: self.conditions,
abilities: self.abilities,
cur_energy: self.cur_energy,
cur_health: self.cur_health,
max_energy: self.max_energy,
max_health: self.max_health,
_p: PhantomData,
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment