summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstuebinm2022-02-01 17:03:57 +0100
committerstuebinm2022-02-01 17:03:57 +0100
commitaacb2d78a4a97e3e8d7fdff4c06cba8be5f3139f (patch)
tree87830cc8c8a1507e869d448decb589073298f734 /src
parent4b596c9c849b310d8b7952a4c16fcdd33b34e902 (diff)
better output if there are no intermediate stops
Diffstat (limited to 'src')
-rw-r--r--src/types.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/types.rs b/src/types.rs
index 3dcb6db..1efd9c1 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -168,15 +168,13 @@ impl std::fmt::Display for Train {
#[allow(unstable_name_collisions)]
impl std::fmt::Display for Trip<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- if self.0.len() == 0 {
- write!(f, "(none)")
- } else {
- self.0.iter()
- .map(|stop| stop.to_fancy_string())
- .intersperse(" ↓".to_string())
- .for_each(|l| writeln!(f, " {}", l).unwrap());
- Ok(())
+ if self.0.len() != 0 {
+ self.0.iter()
+ .map(|stop| stop.to_fancy_string())
+ // .intersperse(" ↓".to_string())
+ .for_each(|l| writeln!(f, " {}\n ↓", l).unwrap());
}
+ Ok(())
}
}
@@ -187,14 +185,14 @@ impl std::fmt::Display for Status {
false => write!(
f,
"not checked in. \n\n\
- last trip: \n {}\n ↓\n {}",
+ last trip: \n {} {}",
self.from_station.to_fancy_string(),
self.to_station.as_ref().unwrap().to_fancy_string()
),
true => write!(
f,
"checked in to: {}.\n\n\
- stops:\n {}\n ↓\n{} ↓\n {}",
+ stops:\n {}\n ↓\n{} {}",
self.train.as_ref().map(|t| t.to_string()).unwrap_or("".to_string()).green(),
self.from_station.to_fancy_string(),
Trip(&self.intermediate_stops),