aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2018-04-15 13:30:29 +0200
committerTeddy Wing2018-04-15 13:30:29 +0200
commit59f47cadefafc126b9c215c511f0fc5adeeabf34 (patch)
treea76feb158c192942857e9994c0b000f88e923aed /src
parent3034dfad17ef8f35d68833fade6e4c1fbad15446 (diff)
downloadmeetup-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')
-rw-r--r--src/meetup_rss.rs9
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)
}