@@ -2493,24 +2493,24 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
2493
2493
}
2494
2494
2495
2495
fn attribute_without_value ( s : & str ) -> bool {
2496
- vec ! ( "must_use" , "no_mangle" , "unsafe_destructor_blind_to_params" ) . iter ( ) . any ( |x| x == & s)
2496
+ [ "must_use" , "no_mangle" , "unsafe_destructor_blind_to_params" ] . iter ( ) . any ( |x| x == & s)
2497
2497
}
2498
2498
2499
2499
fn attribute_with_value ( s : & str ) -> bool {
2500
- vec ! ( "export_name" , "lang" , "link_section" , "must_use" ) . iter ( ) . any ( |x| x == & s)
2500
+ [ "export_name" , "lang" , "link_section" , "must_use" ] . iter ( ) . any ( |x| x == & s)
2501
2501
}
2502
2502
2503
2503
fn attribute_with_values ( s : & str ) -> bool {
2504
- vec ! ( "repr" ) . iter ( ) . any ( |x| x == & s)
2504
+ [ "repr" ] . iter ( ) . any ( |x| x == & s)
2505
2505
}
2506
2506
2507
- fn render_attribute ( attr : & clean:: Attribute , recurse : bool ) -> String {
2507
+ fn render_attribute ( attr : & clean:: Attribute , recurse : bool ) -> Option < String > {
2508
2508
match * attr {
2509
2509
clean:: Word ( ref s) if attribute_without_value ( & * s) || recurse => {
2510
- format ! ( "{}" , s)
2510
+ Some ( format ! ( "{}" , s) )
2511
2511
}
2512
2512
clean:: NameValue ( ref k, ref v) if attribute_with_value ( & * k) => {
2513
- format ! ( "{} = \" {}\" " , k, v)
2513
+ Some ( format ! ( "{} = \" {}\" " , k, v) )
2514
2514
}
2515
2515
clean:: List ( ref k, ref values) if attribute_with_values ( & * k) => {
2516
2516
let mut display = Vec :: new ( ) ;
@@ -2521,21 +2521,25 @@ fn render_attribute(attr: &clean::Attribute, recurse: bool) -> String {
2521
2521
display. push ( format ! ( "{}" , s) ) ;
2522
2522
}
2523
2523
}
2524
- format ! ( "{}({})" , k, display. join( ", " ) )
2524
+ Some ( format ! ( "{}({})" , k, display. join( ", " ) ) )
2525
2525
}
2526
2526
_ => {
2527
- String :: new ( )
2527
+ None
2528
2528
}
2529
2529
}
2530
2530
}
2531
2531
2532
2532
fn render_attributes ( w : & mut fmt:: Formatter , it : & clean:: Item ) -> fmt:: Result {
2533
+ let mut attrs = String :: new ( ) ;
2534
+
2533
2535
for attr in & it. attrs {
2534
- let s = render_attribute ( attr, false ) ;
2535
- if s. len ( ) > 0 {
2536
- write ! ( w, "#[{}]\n " , s) ?;
2536
+ if let Some ( s) = render_attribute ( attr, false ) {
2537
+ attrs. push_str ( & format ! ( "#[{}]\n " , s) ) ;
2537
2538
}
2538
2539
}
2540
+ if attrs. len ( ) > 0 {
2541
+ write ! ( w, "<div class=\" docblock\" >{}</div>" , & attrs) ?;
2542
+ }
2539
2543
Ok ( ( ) )
2540
2544
}
2541
2545
0 commit comments