@@ -6,9 +6,9 @@ use crate::*;
66pub trait Style {
77 fn green ( & self ) -> String ;
88 fn red ( & self ) -> String ;
9- fn dimmed ( & self ) -> String ;
109 fn comment ( & self ) -> String ;
1110 fn tooltip ( & self , text : & str ) -> String ;
11+ fn inherited_ref ( & self ) -> String ;
1212 fn code ( & self ) -> String ;
1313}
1414
@@ -29,14 +29,6 @@ impl Style for &str {
2929 <Self as Colorize >:: red ( self ) . to_string ( )
3030 }
3131 }
32- fn dimmed ( & self ) -> String {
33- if cfg ! ( target_arch = "wasm32" ) {
34- format ! ( "<span style=\" color: gray\" >{self}</span>" )
35- } else {
36- use colored:: Colorize ;
37- <Self as Colorize >:: dimmed ( self ) . to_string ( )
38- }
39- }
4032 fn comment ( & self ) -> String {
4133 if cfg ! ( target_arch = "wasm32" ) {
4234 format ! ( "<span style=\" color: dimgray\" >{self}</span>" )
@@ -52,6 +44,15 @@ impl Style for &str {
5244 self . to_string ( )
5345 }
5446 }
47+ fn inherited_ref ( & self ) -> String {
48+ if cfg ! ( target_arch = "wasm32" ) {
49+ format ! ( "<span class=\" inherited-ref\" >{self}</span>" )
50+ } else {
51+ use colored:: Colorize ;
52+ <Self as Colorize >:: dimmed ( self ) . to_string ( )
53+ }
54+ . tooltip ( "inherited reference" )
55+ }
5556 fn code ( & self ) -> String {
5657 if cfg ! ( target_arch = "wasm32" ) {
5758 format ! ( "<code>{self}</code>" )
@@ -68,8 +69,8 @@ impl Style for String {
6869 fn red ( & self ) -> String {
6970 self . as_str ( ) . red ( )
7071 }
71- fn dimmed ( & self ) -> String {
72- self . as_str ( ) . dimmed ( )
72+ fn inherited_ref ( & self ) -> String {
73+ self . as_str ( ) . inherited_ref ( )
7374 }
7475 fn comment ( & self ) -> String {
7576 self . as_str ( ) . comment ( )
@@ -122,7 +123,7 @@ impl<'a> TypingPredicate<'a> {
122123 let bm = self . expr . binding_mode ( ) . ok ( ) ;
123124 let bm = match toi {
124125 TypeOfInterest :: UserVisible => match bm {
125- Some ( BindingMode :: ByRef ( _) ) => & "inh" . dimmed ( ) . to_string ( ) ,
126+ Some ( BindingMode :: ByRef ( _) ) => & "inh" . inherited_ref ( ) . to_string ( ) ,
126127 _ if !matches ! ( self . expr. ty, Type :: Ref ( ..) | Type :: Abstract ( ..) ) => "_" ,
127128 Some ( BindingMode :: ByMove ) => "real" ,
128129 None => "r" ,
@@ -156,15 +157,9 @@ impl<'a> TypingPredicate<'a> {
156157 && let Some ( BindingMode :: ByRef ( _) ) = self . expr . binding_mode ( ) . ok ( )
157158 {
158159 if let Some ( rest) = ty. strip_prefix ( "&mut" ) {
159- ty = format ! (
160- "{}{rest}" ,
161- "&mut" . dimmed( ) . tooltip( "inherited reference" )
162- ) ;
160+ ty = format ! ( "{}{rest}" , "&mut" . inherited_ref( ) ) ;
163161 } else if let Some ( rest) = ty. strip_prefix ( "&" ) {
164- ty = format ! (
165- "{}{rest}" ,
166- "&" . dimmed( ) . tooltip( "inherited reference" )
167- ) ;
162+ ty = format ! ( "{}{rest}" , "&" . inherited_ref( ) ) ;
168163 }
169164 }
170165 ty
0 commit comments