Mercurial > touhou
diff src/th06/ecl.rs @ 665:965ecdbf0316
Make rank user-defined in eclrenderer.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 11 Aug 2019 20:14:20 +0200 |
parents | f08e8e3c6196 |
children | 1bb8b34dbd32 |
line wrap: on
line diff
--- a/src/th06/ecl.rs +++ b/src/th06/ecl.rs @@ -28,6 +28,20 @@ bitflags! { } } +impl std::str::FromStr for Rank { + type Err = String; + + fn from_str(s: &str) -> Result<Rank, Self::Err> { + Ok(match s { + "easy" => Rank::Easy, + "normal" => Rank::Normal, + "hard" => Rank::Hard, + "lunatic" => Rank::Lunatic, + _ => return Err(format!("unknown rank {}", s)) + }) + } +} + /// A single instruction, part of a `Script`. #[derive(Debug, Clone)] pub struct CallSub {