Removed unnecessary json return data (closes #12)

master
Jef Roosens 2021-04-04 19:15:47 +02:00
parent 6af5368a87
commit 001b7b324e
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
1 changed files with 2 additions and 13 deletions

View File

@ -51,6 +51,7 @@ impl TryFrom<&str> for BasicDate {
match re.captures(s) {
None => Err(()),
Some(caps) => Ok(BasicDate {
// TODO change this to ? operator if possible
year: caps.get(1).unwrap().as_str().parse().unwrap(),
month: caps.get(2).unwrap().as_str().parse().unwrap(),
day: caps.get(3).unwrap().as_str().parse().unwrap(),
@ -86,12 +87,9 @@ impl Serialize for PickupTime {
where
S: Serializer,
{
let mut s = serializer.serialize_struct("PickupTime", 4)?;
let mut s = serializer.serialize_struct("PickupTime", 2)?;
s.serialize_field("date", &self.date)?;
s.serialize_field("label", &self.label)?;
s.serialize_field("classes", &self.classes)?;
s.serialize_field("url", &self.url)?;
s.end()
}
}
@ -101,8 +99,6 @@ impl Serialize for PickupTime {
pub struct PickupTime {
date: BasicDate,
label: String,
classes: Vec<String>,
url: String,
}
pub fn get_pickup_times(
@ -142,13 +138,6 @@ pub fn get_pickup_times(
// TODO should I check here if the parsing worked?
date: BasicDate::try_from(map.get("date").unwrap().as_str()).unwrap(),
label: map.get("label").unwrap().to_string(),
classes: map
.get("classes")
.unwrap()
.split_whitespace()
.map(|x| String::from(x))
.collect(),
url: map.get("url").unwrap().to_string(),
})
}