@@ -47,13 +47,12 @@ pub(crate) enum Tooltip {
4747 CompileFail ,
4848 ShouldPanic ,
4949 Edition ( Edition ) ,
50- None ,
5150}
5251
5352/// Highlights `src` as an inline example, returning the HTML output.
5453pub ( crate ) fn render_example_with_highlighting (
5554 src : & str ,
56- tooltip : & Tooltip ,
55+ tooltip : Option < & Tooltip > ,
5756 playground_button : Option < & str > ,
5857 extra_classes : & [ String ] ,
5958) -> impl Display {
@@ -67,23 +66,24 @@ pub(crate) fn render_example_with_highlighting(
6766fn write_header (
6867 class : & str ,
6968 extra_content : Option < & str > ,
70- tooltip : & Tooltip ,
69+ tooltip : Option < & Tooltip > ,
7170 extra_classes : & [ String ] ,
7271) -> impl Display {
7372 fmt:: from_fn ( move |f| {
7473 write ! (
7574 f,
7675 "<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( )
8484 ) ?;
8585
86- if * tooltip != Tooltip :: None {
86+ if let Some ( tooltip) = tooltip {
8787 let tooltip = fmt:: from_fn ( |f| match tooltip {
8888 Tooltip :: IgnoreAll => f. write_str ( "This example is not tested" ) ,
8989 Tooltip :: IgnoreSome ( platforms) => {
@@ -104,7 +104,6 @@ fn write_header(
104104 Tooltip :: CompileFail => f. write_str ( "This example deliberately fails to compile" ) ,
105105 Tooltip :: ShouldPanic => f. write_str ( "This example panics" ) ,
106106 Tooltip :: Edition ( edition) => write ! ( f, "This example runs with edition {edition}" ) ,
107- Tooltip :: None => unreachable ! ( ) ,
108107 } ) ;
109108
110109 write ! ( f, "<a href=\" #\" class=\" tooltip\" title=\" {tooltip}\" >ⓘ</a>" ) ?;
0 commit comments