mana cost is optional

This commit is contained in:
Adrian Malacoda 2017-05-16 21:37:54 -05:00
parent 28084f8848
commit 1fbb78c915

View File

@ -23,7 +23,7 @@ const RETRY_WAIT_MILLIS: u64 = 500;
#[derive(Debug)] #[derive(Debug)]
pub struct MtgCard { pub struct MtgCard {
pub name: String, pub name: String,
pub cost: String, pub cost: Option<String>,
pub typeline: String, pub typeline: String,
pub rules: String, pub rules: String,
pub flavor: Option<String>, pub flavor: Option<String>,
@ -78,7 +78,7 @@ fn parse_entry (page: String) -> Result<MtgCard, Error> {
return Result::Ok(MtgCard { return Result::Ok(MtgCard {
name: card_name, name: card_name,
cost: entry["manaCost"].as_str().map(String::from).expect("expected cost in json data"), cost: entry["manaCost"].as_str().map(String::from),
typeline: entry["type"].as_str().map(String::from).expect("expected type in json data"), typeline: entry["type"].as_str().map(String::from).expect("expected type in json data"),
rules: entry["text"].as_str().map(String::from).expect("expected text in json data"), rules: entry["text"].as_str().map(String::from).expect("expected text in json data"),
flavor: entry["flavor"].as_str().map(String::from), flavor: entry["flavor"].as_str().map(String::from),