Display #[non_exhaustive] in rustdoc on types.
This commit is contained in:
parent
ed0350e945
commit
a074bd7334
8 changed files with 75 additions and 3 deletions
|
@ -2194,6 +2194,7 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
|
|||
info!("Documenting {}", name);
|
||||
}
|
||||
document_stability(w, cx, item)?;
|
||||
document_non_exhaustive(w, item)?;
|
||||
let prefix = render_assoc_const_value(item);
|
||||
document_full(w, item, cx, &prefix)?;
|
||||
Ok(())
|
||||
|
@ -2262,6 +2263,28 @@ fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item)
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
|
||||
if item.non_exhaustive {
|
||||
write!(w, r##"
|
||||
<div class='non-exhaustive'>
|
||||
<div class='stab non-exhaustive'>
|
||||
<details>
|
||||
<summary>
|
||||
<span class=microscope>🔬</span>
|
||||
This type is marked as non exhaustive.
|
||||
</summary>
|
||||
<p>
|
||||
This type will require a wildcard arm in any match statements or constructors.
|
||||
</p>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
"##)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn name_key(name: &str) -> (&str, u64, usize) {
|
||||
// find number at end
|
||||
let split = name.bytes().rposition(|b| b < b'0' || b'9' < b).map_or(0, |s| s + 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue