@@ -47,13 +47,12 @@ pub(crate) enum Tooltip {
47
47
CompileFail ,
48
48
ShouldPanic ,
49
49
Edition ( Edition ) ,
50
- None ,
51
50
}
52
51
53
52
/// Highlights `src` as an inline example, returning the HTML output.
54
53
pub ( crate ) fn render_example_with_highlighting (
55
54
src : & str ,
56
- tooltip : & Tooltip ,
55
+ tooltip : Option < & Tooltip > ,
57
56
playground_button : Option < & str > ,
58
57
extra_classes : & [ String ] ,
59
58
) -> impl Display {
@@ -67,23 +66,24 @@ pub(crate) fn render_example_with_highlighting(
67
66
fn write_header (
68
67
class : & str ,
69
68
extra_content : Option < & str > ,
70
- tooltip : & Tooltip ,
69
+ tooltip : Option < & Tooltip > ,
71
70
extra_classes : & [ String ] ,
72
71
) -> impl Display {
73
72
fmt:: from_fn ( move |f| {
74
73
write ! (
75
74
f,
76
75
"<div class=\" example-wrap{}\" >" ,
77
- match tooltip {
78
- Tooltip :: IgnoreAll | Tooltip :: IgnoreSome ( _) => " ignore" ,
79
- Tooltip :: CompileFail => " compile_fail" ,
80
- Tooltip :: ShouldPanic => " should_panic" ,
81
- Tooltip :: Edition ( _) => " edition" ,
82
- Tooltip :: None => "" ,
83
- }
76
+ tooltip
77
+ . map( |tooltip| match tooltip {
78
+ Tooltip :: IgnoreAll | Tooltip :: IgnoreSome ( _) => " ignore" ,
79
+ Tooltip :: CompileFail => " compile_fail" ,
80
+ Tooltip :: ShouldPanic => " should_panic" ,
81
+ Tooltip :: Edition ( _) => " edition" ,
82
+ } )
83
+ . unwrap_or_default( )
84
84
) ?;
85
85
86
- if * tooltip != Tooltip :: None {
86
+ if let Some ( tooltip) = tooltip {
87
87
let tooltip = fmt:: from_fn ( |f| match tooltip {
88
88
Tooltip :: IgnoreAll => f. write_str ( "This example is not tested" ) ,
89
89
Tooltip :: IgnoreSome ( platforms) => {
@@ -104,7 +104,6 @@ fn write_header(
104
104
Tooltip :: CompileFail => f. write_str ( "This example deliberately fails to compile" ) ,
105
105
Tooltip :: ShouldPanic => f. write_str ( "This example panics" ) ,
106
106
Tooltip :: Edition ( edition) => write ! ( f, "This example runs with edition {edition}" ) ,
107
- Tooltip :: None => unreachable ! ( ) ,
108
107
} ) ;
109
108
110
109
write ! ( f, "<a href=\" #\" class=\" tooltip\" title=\" {tooltip}\" >ⓘ</a>" ) ?;
0 commit comments