Skip to content

Commit

Permalink
Merge pull request #52 from mlevesquedion/refactor/use-join-instead-o…
Browse files Browse the repository at this point in the history
…f-flag

Use `join` instead of a `first` flag.
  • Loading branch information
kurtlawrence authored May 14, 2019
2 parents 587c9b5 + 99e8032 commit be3db6b
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<&str>>()
.join(";")
}

pub fn new(from: Styles) -> Style {
Expand Down

0 comments on commit be3db6b

Please sign in to comment.