Skip to content

rustdoc: Only include a stability span if needed. #39740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 12, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use functional transformations on the option instead of matching.
  • Loading branch information
jimmycuadra committed Feb 11, 2017
commit 1fa9dbc00e8d5eff8f698097afb112c142bb8da0
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