提交 1fa9dbc0 编写于 作者: J Jimmy Cuadra

Use functional transformations on the option instead of matching.

上级 bd14c7f3
......@@ -328,26 +328,23 @@ pub fn has_stripped_fields(&self) -> Option<bool> {
}
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> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册