2019-05-25 10:42:34 +00:00
|
|
|
|
|
|
|
<style>
|
2019-07-18 15:49:32 +00:00
|
|
|
body { margin: 0; }
|
|
|
|
pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; }
|
|
|
|
|
|
|
|
.comment { color: #7F9F7F; }
|
|
|
|
.string { color: #CC9393; }
|
|
|
|
.function { color: #93E0E3; }
|
|
|
|
.parameter { color: #94BFF3; }
|
|
|
|
.builtin { color: #DD6718; }
|
|
|
|
.text { color: #DCDCCC; }
|
2019-07-18 16:57:13 +00:00
|
|
|
.attribute { color: #94BFF3; }
|
|
|
|
.literal { color: #BFEBBF; }
|
|
|
|
.macro { color: #94BFF3; }
|
|
|
|
.variable { color: #DCDCCC; }
|
|
|
|
.variable\.mut { color: #DCDCCC; text-decoration: underline; }
|
2019-07-18 15:49:32 +00:00
|
|
|
|
|
|
|
.keyword { color: #F0DFAF; }
|
2019-07-18 16:57:13 +00:00
|
|
|
.keyword\.unsafe { color: #DFAF8F; }
|
|
|
|
.keyword\.control { color: #F0DFAF; font-weight: bold; }
|
2019-05-25 10:42:34 +00:00
|
|
|
</style>
|
2019-09-29 21:15:03 +00:00
|
|
|
<pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="attribute text">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>
|
2019-05-28 18:27:54 +00:00
|
|
|
<span class="keyword">struct</span> <span class="type">Foo</span> {
|
2019-08-21 23:08:07 +00:00
|
|
|
<span class="keyword">pub</span> <span class="field">x</span>: <span class="type">i32</span>,
|
|
|
|
<span class="keyword">pub</span> <span class="field">y</span>: <span class="type">i32</span>,
|
2019-05-25 10:42:34 +00:00
|
|
|
}
|
|
|
|
|
2019-05-29 17:48:09 +00:00
|
|
|
<span class="keyword">fn</span> <span class="function">foo</span><<span class="type">T</span>>() -> <span class="type">T</span> {
|
2019-05-25 10:42:34 +00:00
|
|
|
<span class="macro">unimplemented</span><span class="macro">!</span>();
|
2019-05-29 17:48:09 +00:00
|
|
|
<span class="function">foo</span>::<<span class="type">i32</span>>();
|
2019-05-25 10:42:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
<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">"Hello, {}!"</span>, <span class="literal">92</span>);
|
|
|
|
|
2019-07-18 15:49:32 +00:00
|
|
|
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>();
|
2019-05-25 10:42:34 +00:00
|
|
|
<span class="keyword.control">if</span> <span class="keyword">true</span> {
|
2019-07-18 15:49:32 +00:00
|
|
|
<span class="variable.mut">vec</span>.<span class="text">push</span>(<span class="type">Foo</span> { <span class="field">x</span>: <span class="literal">0</span>, <span class="field">y</span>: <span class="literal">1</span> });
|
2019-05-25 10:42:34 +00:00
|
|
|
}
|
2019-07-18 15:49:32 +00:00
|
|
|
<span class="keyword.unsafe">unsafe</span> { <span class="variable.mut">vec</span>.<span class="text">set_len</span>(<span class="literal">0</span>); }
|
|
|
|
|
|
|
|
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut">x</span> = <span class="literal">42</span>;
|
|
|
|
<span class="keyword">let</span> <span class="variable.mut">y</span> = &<span class="keyword">mut</span> <span class="variable.mut">x</span>;
|
|
|
|
<span class="keyword">let</span> <span class="variable">z</span> = &<span class="variable.mut">y</span>;
|
|
|
|
|
|
|
|
<span class="variable.mut">y</span>;
|
2019-05-25 14:23:58 +00:00
|
|
|
}</code></pre>
|