Skip to content

Commit

Permalink
Use functional transformations on the option instead of matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed Feb 11, 2017
1 parent bd14c7f commit 1fa9dbc
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,26 +328,23 @@ impl Item {
}

pub fn stability_class(&self) -> Option<String> {
match self.stability {
Some(ref s) => {
let mut classes = Vec::with_capacity(2);
self.stability.as_ref().and_then(|ref s| {
let mut classes = Vec::with_capacity(2);

if s.level == stability::Unstable {
classes.push("unstable");
}
if s.level == stability::Unstable {
classes.push("unstable");
}

if !s.deprecated_since.is_empty() {
classes.push("deprecated");
}
if !s.deprecated_since.is_empty() {
classes.push("deprecated");
}

if classes.len() != 0 {
Some(classes.join(" "))
} else {
None
}
if classes.len() != 0 {
Some(classes.join(" "))
} else {
None
}
None => None,
}
})
}

pub fn stable_since(&self) -> Option<&str> {
Expand Down

0 comments on commit 1fa9dbc

Please sign in to comment.