From 99e8032f092f2c642469803c1e484d842c6ace75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20L=C3=A9vesque-Dion?= Date: Sun, 5 May 2019 23:10:21 -0400 Subject: [PATCH] Use `join` instead of a `first` flag. --- src/style.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/style.rs b/src/style.rs index be5babb..ba2d869 100644 --- a/src/style.rs +++ b/src/style.rs @@ -86,24 +86,12 @@ impl Styles { impl Style { pub fn to_str(self) -> String { - let styles = match Styles::from_u8(self.0) { - None => return String::new(), - Some(s) => s, - }; - let mut res = String::new(); - let mut first = true; - - for style in styles.iter().map(|s| s.to_str()) { - if first { - res.push_str(style); - first = false; - continue; - } else { - res.push(';'); - res.push_str(style) - } - } - res + let styles = Styles::from_u8(self.0).unwrap_or(Vec::new()); + styles + .iter() + .map(|s| s.to_str()) + .collect::>() + .join(";") } pub fn new(from: Styles) -> Style {