Skip to content

Commit 1fa9dbc

Browse files
committed
Use functional transformations on the option instead of matching.
1 parent bd14c7f commit 1fa9dbc

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/librustdoc/clean/mod.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -328,26 +328,23 @@ impl Item {
328328
}
329329

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

335-
if s.level == stability::Unstable {
336-
classes.push("unstable");
337-
}
334+
if s.level == stability::Unstable {
335+
classes.push("unstable");
336+
}
338337

339-
if !s.deprecated_since.is_empty() {
340-
classes.push("deprecated");
341-
}
338+
if !s.deprecated_since.is_empty() {
339+
classes.push("deprecated");
340+
}
342341

343-
if classes.len() != 0 {
344-
Some(classes.join(" "))
345-
} else {
346-
None
347-
}
342+
if classes.len() != 0 {
343+
Some(classes.join(" "))
344+
} else {
345+
None
348346
}
349-
None => None,
350-
}
347+
})
351348
}
352349

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

0 commit comments

Comments
 (0)