aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/snapshots/highlighting.html
blob: 8c372ad2700b667b11e2dd6333093f2d51ab0a14 (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
<style>
body                { margin: 0; }
pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; }


.comment            { color: #7F9F7F; }
.struct, .enum      { color: #7CB8BB; }
.enum_variant       { color: #BDE0F3; }
.string_literal     { color: #CC9393; }
.field              { color: #94BFF3; }
.function           { color: #93E0E3; }
.parameter          { color: #94BFF3; }
.text               { color: #DCDCCC; }
.type               { color: #7CB8BB; }
.builtin_type       { color: #8CD0D3; }
.type_param         { color: #DFAF8F; }
.attribute          { color: #94BFF3; }
.numeric_literal    { color: #BFEBBF; }
.macro              { color: #94BFF3; }
.module             { color: #AFD8AF; }
.variable           { color: #DCDCCC; }
.mutable            { text-decoration: underline; }

.keyword            { color: #F0DFAF; font-weight: bold; }
.keyword.unsafe     { color: #BC8383; font-weight: bold; }
.control            { font-style: italic; }
</style>
<pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="attribute">derive</span><span class="attribute">(</span><span class="attribute">Clone</span><span class="attribute">,</span><span class="attribute"> </span><span class="attribute">Debug</span><span class="attribute">)</span><span class="attribute">]</span>
<span class="keyword">struct</span> <span class="struct">Foo</span> {
    <span class="keyword">pub</span> <span class="field">x</span>: <span class="builtin_type">i32</span>,
    <span class="keyword">pub</span> <span class="field">y</span>: <span class="builtin_type">i32</span>,
}

<span class="keyword">fn</span> <span class="function">foo</span>&lt;<span class="type_param">T</span>&gt;() -&gt; <span class="type_param">T</span> {
    <span class="macro">unimplemented</span><span class="macro">!</span>();
    <span class="function">foo</span>::&lt;<span class="builtin_type">i32</span>&gt;();
}

<span class="macro">macro_rules</span><span class="macro">!</span> def_fn {
    ($($tt:tt)*) =&gt; {$($tt)*}
}

<span class="macro">def_fn</span><span class="macro">!</span> {
    <span class="keyword">fn</span> <span class="function">bar</span>() -&gt; <span class="builtin_type">u32</span> {
        <span class="numeric_literal">100</span>
    }
}

<span class="comment">// comment</span>
<span class="keyword">fn</span> <span class="function">main</span>() {
    <span class="macro">println</span><span class="macro">!</span>(<span class="string_literal">"Hello, {}!"</span>, <span class="numeric_literal">92</span>);

    <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable mutable">vec</span> = Vec::new();
    <span class="keyword control">if</span> <span class="keyword">true</span> {
        <span class="keyword">let</span> <span class="variable">x</span> = <span class="numeric_literal">92</span>;
        <span class="variable mutable">vec</span>.push(<span class="struct">Foo</span> { <span class="field">x</span>, <span class="field">y</span>: <span class="numeric_literal">1</span> });
    }
    <span class="keyword unsafe">unsafe</span> { <span class="variable mutable">vec</span>.set_len(<span class="numeric_literal">0</span>); }

    <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable mutable">x</span> = <span class="numeric_literal">42</span>;
    <span class="keyword">let</span> <span class="variable mutable">y</span> = &<span class="keyword">mut</span> <span class="variable mutable">x</span>;
    <span class="keyword">let</span> <span class="variable">z</span> = &<span class="variable mutable">y</span>;

    <span class="variable mutable">y</span>;
}

<span class="keyword">enum</span> <span class="enum">E</span>&lt;<span class="type_param">X</span>&gt; {
    <span class="enum_variant">V</span>(<span class="type_param">X</span>)
}

<span class="keyword">impl</span>&lt;<span class="type_param">X</span>&gt; <span class="enum">E</span>&lt;<span class="type_param">X</span>&gt; {
    <span class="keyword">fn</span> <span class="function">new</span>&lt;<span class="type_param">T</span>&gt;() -&gt; <span class="enum">E</span>&lt;<span class="type_param">T</span>&gt; {}
}</code></pre>