rustdoc: Show must_use attribute
This commit is contained in:
parent
5936278ed6
commit
995b159157
3 changed files with 47 additions and 1 deletions
|
@ -1849,6 +1849,7 @@ fn render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result {
|
|||
fn item_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
||||
s: &clean::Struct) -> fmt::Result {
|
||||
try!(write!(w, "<pre class='rust struct'>"));
|
||||
try!(render_attributes(w, it));
|
||||
try!(render_struct(w,
|
||||
it,
|
||||
Some(&s.generics),
|
||||
|
@ -1885,7 +1886,9 @@ fn item_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
|||
|
||||
fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
|
||||
e: &clean::Enum) -> fmt::Result {
|
||||
try!(write!(w, "<pre class='rust enum'>{}enum {}{}{}",
|
||||
try!(write!(w, "<pre class='rust enum'>"));
|
||||
try!(render_attributes(w, it));
|
||||
try!(write!(w, "{}enum {}{}{}",
|
||||
VisSpace(it.visibility),
|
||||
it.name.as_ref().unwrap(),
|
||||
e.generics,
|
||||
|
@ -1982,6 +1985,21 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
|
||||
for attr in &it.attrs {
|
||||
match *attr {
|
||||
clean::Word(ref s) if *s == "must_use" => {
|
||||
try!(write!(w, "#[{}]\n", s));
|
||||
}
|
||||
clean::NameValue(ref k, ref v) if *k == "must_use" => {
|
||||
try!(write!(w, "#[{} = \"{}\"]\n", k, v));
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
|
||||
g: Option<&clean::Generics>,
|
||||
ty: doctree::StructType,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue