aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/test_data/highlight_strings.html
blob: 1ee7bdee4913c6f5087f0e2788166f44eeeabdc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<style>
body                { margin: 0; }
pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; }

.lifetime           { color: #DFAF8F; font-style: italic; }
.comment            { color: #7F9F7F; }
.documentation      { color: #629755; }
.injected           { opacity: 0.65 ; }
.struct, .enum      { color: #7CB8BB; }
.enum_variant       { color: #BDE0F3; }
.string_literal     { color: #CC9393; }
.field              { color: #94BFF3; }
.function           { color: #93E0E3; }
.function.unsafe    { color: #BC8383; }
.operator.unsafe    { color: #BC8383; }
.parameter          { color: #94BFF3; }
.text               { color: #DCDCCC; }
.type               { color: #7CB8BB; }
.builtin_type       { color: #8CD0D3; }
.type_param         { color: #DFAF8F; }
.attribute          { color: #94BFF3; }
.numeric_literal    { color: #BFEBBF; }
.bool_literal       { color: #BFE6EB; }
.macro              { color: #94BFF3; }
.module             { color: #AFD8AF; }
.value_param        { color: #DCDCCC; }
.variable           { color: #DCDCCC; }
.format_specifier   { color: #CC696B; }
.mutable            { text-decoration: underline; }
.escape_sequence    { color: #94BFF3; }
.keyword            { color: #F0DFAF; font-weight: bold; }
.keyword.unsafe     { color: #BC8383; font-weight: bold; }
.control            { font-style: italic; }

.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
</style>
<pre><code><span class="macro">macro_rules!</span> <span class="macro declaration">println</span> <span class="operator">{</span>
    <span class="operator">(</span><span class="operator">$</span><span class="operator">(</span><span class="operator">$</span>arg<span class="operator">:</span>tt<span class="operator">)</span>*<span class="operator">)</span> <span class="operator">=</span><span class="operator">&gt;</span> <span class="operator">(</span><span class="operator">{</span>
        <span class="operator">$</span><span class="keyword">crate</span><span class="operator">:</span><span class="operator">:</span>io<span class="operator">:</span><span class="operator">:</span>_print<span class="operator">(</span><span class="operator">$</span><span class="keyword">crate</span><span class="operator">:</span><span class="operator">:</span>format_args_nl<span class="operator">!</span><span class="operator">(</span><span class="operator">$</span><span class="operator">(</span><span class="operator">$</span>arg<span class="operator">)</span>*<span class="operator">)</span><span class="operator">)</span><span class="operator">;</span>
    <span class="operator">}</span><span class="operator">)</span>
<span class="operator">}</span>
#[rustc_builtin_macro]
<span class="macro">macro_rules!</span> <span class="macro declaration">format_args_nl</span> <span class="operator">{</span>
    <span class="operator">(</span><span class="operator">$</span>fmt<span class="operator">:</span>expr<span class="operator">)</span> <span class="operator">=</span><span class="operator">&gt;</span> <span class="operator">{</span><span class="operator">{</span> <span class="comment">/* compiler built-in */</span> <span class="operator">}</span><span class="operator">}</span><span class="operator">;</span>
    <span class="operator">(</span><span class="operator">$</span>fmt<span class="operator">:</span>expr<span class="operator">,</span> <span class="operator">$</span><span class="operator">(</span><span class="operator">$</span>args<span class="operator">:</span>tt<span class="operator">)</span>*<span class="operator">)</span> <span class="operator">=</span><span class="operator">&gt;</span> <span class="operator">{</span><span class="operator">{</span> <span class="comment">/* compiler built-in */</span> <span class="operator">}</span><span class="operator">}</span><span class="operator">;</span>
<span class="operator">}</span>

<span class="keyword">fn</span> <span class="function declaration">main</span><span class="operator">(</span><span class="operator">)</span> <span class="operator">{</span>
    <span class="comment">// from https://doc.rust-lang.org/std/fmt/index.html</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello"</span><span class="operator">)</span><span class="operator">;</span>                 <span class="comment">// =&gt; "Hello"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello, </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="string_literal">"world"</span><span class="operator">)</span><span class="operator">;</span>   <span class="comment">// =&gt; "Hello, world!"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"The number is </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="numeric_literal">1</span><span class="operator">)</span><span class="operator">;</span>   <span class="comment">// =&gt; "The number is 1"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">?</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="operator">(</span><span class="numeric_literal">3</span><span class="operator">,</span> <span class="numeric_literal">4</span><span class="operator">)</span><span class="operator">)</span><span class="operator">;</span>          <span class="comment">// =&gt; "(3, 4)"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">value</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> value<span class="operator">=</span><span class="numeric_literal">4</span><span class="operator">)</span><span class="operator">;</span>      <span class="comment">// =&gt; "4"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="numeric_literal">1</span><span class="operator">,</span> <span class="numeric_literal">2</span><span class="operator">)</span><span class="operator">;</span>           <span class="comment">// =&gt; "1 2"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="numeric_literal">4</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="numeric_literal">42</span><span class="operator">)</span><span class="operator">;</span>             <span class="comment">// =&gt; "0042" with leading zerosV</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="numeric_literal">0</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="numeric_literal">1</span><span class="operator">,</span> <span class="numeric_literal">2</span><span class="operator">)</span><span class="operator">;</span>   <span class="comment">// =&gt; "2 1 1 2"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">argument</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> argument <span class="operator">=</span> <span class="string_literal">"test"</span><span class="operator">)</span><span class="operator">;</span>   <span class="comment">// =&gt; "test"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="numeric_literal">1</span><span class="operator">,</span> name <span class="operator">=</span> <span class="numeric_literal">2</span><span class="operator">)</span><span class="operator">;</span>          <span class="comment">// =&gt; "2 1"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">a</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="variable">c</span><span class="format_specifier">}</span><span class="string_literal"> </span><span class="format_specifier">{</span><span class="variable">b</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> a<span class="operator">=</span><span class="string_literal">"a"</span><span class="operator">,</span> b<span class="operator">=</span><span class="char_literal">'b'</span><span class="operator">,</span> c<span class="operator">=</span><span class="numeric_literal">3</span><span class="operator">)</span><span class="operator">;</span>  <span class="comment">// =&gt; "a 3 b"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"{{</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">}}"</span><span class="operator">,</span> <span class="numeric_literal">2</span><span class="operator">)</span><span class="operator">;</span>                       <span class="comment">// =&gt; "{2}"</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">1</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">,</span> <span class="numeric_literal">5</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="numeric_literal">5</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="variable">width</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">,</span> width <span class="operator">=</span> <span class="numeric_literal">5</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">&lt;</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">-</span><span class="format_specifier">&lt;</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">^</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">&gt;</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">+</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="numeric_literal">5</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">#</span><span class="variable">x</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="numeric_literal">27</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="numeric_literal">5</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="numeric_literal">0</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="operator">-</span><span class="numeric_literal">5</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">#</span><span class="numeric_literal">0</span><span class="numeric_literal">10</span><span class="variable">x</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="numeric_literal">27</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">0</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">,</span> <span class="numeric_literal">0.01</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">1</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">2</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="numeric_literal">0</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="numeric_literal">5</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">,</span> <span class="numeric_literal">0.01</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="numeric_literal">0</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">2</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="numeric_literal">1</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">,</span> <span class="numeric_literal">5</span><span class="operator">,</span> <span class="numeric_literal">0.01</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span>    <span class="string_literal">"x"</span><span class="operator">,</span> <span class="numeric_literal">5</span><span class="operator">,</span> <span class="numeric_literal">0.01</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="numeric_literal">2</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span>   <span class="string_literal">"x"</span><span class="operator">,</span> <span class="numeric_literal">5</span><span class="operator">,</span> <span class="numeric_literal">0.01</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal"> is </span><span class="format_specifier">{</span><span class="variable">number</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="variable">prec</span><span class="format_specifier">$</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> <span class="string_literal">"x"</span><span class="operator">,</span> prec <span class="operator">=</span> <span class="numeric_literal">5</span><span class="operator">,</span> number <span class="operator">=</span> <span class="numeric_literal">0.01</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">, `</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">` has 3 fractional digits"</span><span class="operator">,</span> <span class="string_literal">"Hello"</span><span class="operator">,</span> <span class="numeric_literal">3</span><span class="operator">,</span> name<span class="operator">=</span><span class="numeric_literal">1234.56</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">, `</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">:</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">` has 3 characters"</span><span class="operator">,</span> <span class="string_literal">"Hello"</span><span class="operator">,</span> <span class="numeric_literal">3</span><span class="operator">,</span> name<span class="operator">=</span><span class="string_literal">"1234.56"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">, `</span><span class="format_specifier">{</span><span class="variable">name</span><span class="format_specifier">:</span><span class="format_specifier">&gt;</span><span class="numeric_literal">8</span><span class="format_specifier">.</span><span class="format_specifier">*</span><span class="format_specifier">}</span><span class="string_literal">` has 3 right-aligned characters"</span><span class="operator">,</span> <span class="string_literal">"Hello"</span><span class="operator">,</span> <span class="numeric_literal">3</span><span class="operator">,</span> name<span class="operator">=</span><span class="string_literal">"1234.56"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello {{}}"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"{{ Hello"</span><span class="operator">)</span><span class="operator">;</span>

    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">r"Hello, </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">!"</span><span class="operator">,</span> <span class="string_literal">"world"</span><span class="operator">)</span><span class="operator">;</span>

    <span class="comment">// escape sequences</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello</span><span class="escape_sequence">\n</span><span class="string_literal">World"</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="escape_sequence">\u{48}</span><span class="escape_sequence">\x65</span><span class="escape_sequence">\x6C</span><span class="escape_sequence">\x6C</span><span class="escape_sequence">\x6F</span><span class="string_literal"> World"</span><span class="operator">)</span><span class="operator">;</span>

    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="escape_sequence">\x41</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> A <span class="operator">=</span> <span class="numeric_literal">92</span><span class="operator">)</span><span class="operator">;</span>
    <span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"</span><span class="format_specifier">{</span><span class="variable">ничоси</span><span class="format_specifier">}</span><span class="string_literal">"</span><span class="operator">,</span> ничоси <span class="operator">=</span> <span class="numeric_literal">92</span><span class="operator">)</span><span class="operator">;</span>
<span class="operator">}</span></code></pre>