summaryrefslogtreecommitdiffstats
path: root/src/print.rs
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-04-12 23:06:48 -0400
committerMatan Kushner <hello@matchai.me>2019-04-12 23:06:48 -0400
commit9d4492c313220ee128a49e01dd3580d22450cd04 (patch)
treeaa5434e10f114c1bde36b3554cace0bde26e3ec0 /src/print.rs
parentd62bb107f231c3d0ebf47b7c91f26348213d8386 (diff)
Make segments optionals
Diffstat (limited to 'src/print.rs')
-rw-r--r--src/print.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/print.rs b/src/print.rs
index 19b13ec4d..cc1719199 100644
--- a/src/print.rs
+++ b/src/print.rs
@@ -18,7 +18,9 @@ pub fn prompt(args: ArgMatches) {
default_prompt
.iter()
- .map(|module| modules::handle(module, &args))
- .map(|segment| segment.output())
+ .map(|module| modules::handle(module, &args)) // Compute segments
+ .flatten() // Remove segments set to `None`
+ .enumerate() // Turn segment into tuple with index
+ .map(|(index, segment)| segment.output(index)) // Generate string outputs
.for_each(|segment_string| write!(handle, "{}", segment_string).unwrap());
}