diff options
author | Teddy Wing | 2018-04-15 13:30:29 +0200 |
---|---|---|
committer | Teddy Wing | 2018-04-15 13:30:29 +0200 |
commit | 59f47cadefafc126b9c215c511f0fc5adeeabf34 (patch) | |
tree | a76feb158c192942857e9994c0b000f88e923aed /src/meetup_rss.rs | |
parent | 3034dfad17ef8f35d68833fade6e4c1fbad15446 (diff) | |
download | meetup-find-events-rss-59f47cadefafc126b9c215c511f0fc5adeeabf34.tar.bz2 |
meetup_rss: Create `join_nonempty` function
Move the join logic from `description_header` into a new function so we
can reuse it.
Diffstat (limited to 'src/meetup_rss.rs')
-rw-r--r-- | src/meetup_rss.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/meetup_rss.rs b/src/meetup_rss.rs index 80409f9..4055ac0 100644 --- a/src/meetup_rss.rs +++ b/src/meetup_rss.rs @@ -73,12 +73,17 @@ fn description_header(event: &Event) -> String { "".to_owned() }; - [when, place] + join_nonempty(&[when, place], "\n") +} + +/// Joins a slice of `String`s with `separator`, filtering out empty strings. +fn join_nonempty(strings: &[String], separator: &str) -> String { + strings .iter() .filter(|s| !s.is_empty()) .map(|s| s.to_owned()) .collect::<Vec<String>>() - .join("\n") + .join(separator) } |