make rules text an Option, it's not always present

This commit is contained in:
Adrian Malacoda 2018-02-22 03:16:59 -06:00
parent 1fbb78c915
commit d0ca8434b5

View File

@ -25,7 +25,7 @@ pub struct MtgCard {
pub name: String,
pub cost: Option<String>,
pub typeline: String,
pub rules: String,
pub rules: Option<String>,
pub flavor: Option<String>,
pub power: Option<String>,
pub toughness: Option<String>,
@ -80,7 +80,7 @@ fn parse_entry (page: String) -> Result<MtgCard, Error> {
name: card_name,
cost: entry["manaCost"].as_str().map(String::from),
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),
flavor: entry["flavor"].as_str().map(String::from),
power: entry["power"].as_str().map(String::from),
toughness: entry["toughness"].as_str().map(String::from),