Use functional transformations on the option instead of matching.
This commit is contained in:
parent
bd14c7f333
commit
1fa9dbc00e
1 changed files with 15 additions and 18 deletions
|
|
@ -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.deprecated_since.is_empty() {
|
||||
classes.push("deprecated");
|
||||
}
|
||||
|
||||
if classes.len() != 0 {
|
||||
Some(classes.join(" "))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if s.level == stability::Unstable {
|
||||
classes.push("unstable");
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
|
||||
if !s.deprecated_since.is_empty() {
|
||||
classes.push("deprecated");
|
||||
}
|
||||
|
||||
if classes.len() != 0 {
|
||||
Some(classes.join(" "))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn stable_since(&self) -> Option<&str> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue