add number stops from args

This commit is contained in:
Dr. Matthias Ratajczak
2023-01-05 14:16:39 +01:00
parent 65881f7174
commit ffcc319650
5 changed files with 98 additions and 44 deletions
+5 -5
View File
@@ -85,15 +85,15 @@ pub struct PointFinderResponse {
pub struct Point {
pub stopid: String,
pub name: String,
pub area: Option<String>,
pub area: String,
}
impl From<(&str, &str, Option<&str>)> for Point {
fn from(value: (&str, &str, Option<&str>)) -> Self {
impl From<(&str, &str, &str)> for Point {
fn from(value: (&str, &str, &str)) -> Self {
Self {
stopid: value.0.into(),
name: value.1.into(),
area: value.2.map(|s| s.into()),
area: value.2.into(),
}
}
}
@@ -104,7 +104,7 @@ fn extract_data_from_response(line: &str) -> Result<Point> {
let mut iter = line.trim_start_matches("\\\"").split_terminator('|');
let stopid = iter.next().context("getting stopid from line")?;
let area = iter.nth(1).context("getting area from line").ok();
let area = iter.nth(1).context("getting area from line")?;
let name = iter.next().context("getting stop name from line")?;
Ok((stopid, name, area).into())
}