mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Highlight punctuation as HighlightTag::Operator
This commit is contained in:
parent
57652fc9d4
commit
33832d43fc
7 changed files with 188 additions and 187 deletions
|
@ -553,6 +553,7 @@ fn highlight_element(
|
|||
T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => {
|
||||
Highlight::new(HighlightTag::Macro)
|
||||
}
|
||||
p if p.is_punct() => HighlightTag::Operator.into(),
|
||||
|
||||
k if k.is_keyword() => {
|
||||
let h = Highlight::new(HighlightTag::Keyword);
|
||||
|
|
|
@ -36,67 +36,67 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
||||
</style>
|
||||
<pre><code><span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> _ = </span><span class="string_literal injected">"early doctests should not go boom"</span><span class="generic injected">;</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="keyword">struct</span> <span class="struct declaration">Foo</span> {
|
||||
<span class="field declaration">bar</span>: <span class="builtin_type">bool</span>,
|
||||
}
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="operator injected">_</span><span class="generic injected"> </span><span class="operator injected">=</span><span class="generic injected"> </span><span class="string_literal injected">"early doctests should not go boom"</span><span class="operator injected">;</span><span class="operator injected">
|
||||
</span><span class="comment documentation">/// ```</span>
|
||||
<span class="keyword">struct</span> <span class="struct declaration">Foo</span> <span class="operator">{</span>
|
||||
<span class="field declaration">bar</span><span class="operator">:</span> <span class="builtin_type">bool</span><span class="operator">,</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="keyword">impl</span> <span class="struct">Foo</span> {
|
||||
<span class="keyword">pub</span> <span class="keyword">const</span> <span class="constant declaration">bar</span>: <span class="builtin_type">bool</span> = <span class="bool_literal">true</span>;
|
||||
<span class="keyword">impl</span> <span class="struct">Foo</span> <span class="operator">{</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">const</span> <span class="constant declaration">bar</span><span class="operator">:</span> <span class="builtin_type">bool</span> <span class="operator">=</span> <span class="bool_literal">true</span><span class="operator">;</span>
|
||||
|
||||
<span class="comment documentation">/// Constructs a new `Foo`.</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// # Examples</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">/// #</span><span class="generic injected"> </span><span class="attribute injected">#![</span><span class="function attribute injected">allow</span><span class="attribute injected">(unused_mut)]</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="keyword injected">mut</span><span class="generic injected"> </span><span class="variable declaration injected mutable">foo</span><span class="generic injected">: </span><span class="struct injected">Foo</span><span class="generic injected"> = </span><span class="struct injected">Foo</span><span class="generic injected">::</span><span class="function injected">new</span><span class="generic injected">();</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration">new</span>() -> <span class="struct">Foo</span> {
|
||||
<span class="struct">Foo</span> { <span class="field">bar</span>: <span class="bool_literal">true</span> }
|
||||
}
|
||||
<span class="comment documentation">/// #</span><span class="generic injected"> </span><span class="operator injected">#</span><span class="operator injected">!</span><span class="operator injected">[</span><span class="function attribute injected">allow</span><span class="operator injected">(</span><span class="attribute injected">unused_mut</span><span class="operator injected">)</span><span class="operator injected">]</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="keyword injected">mut</span><span class="generic injected"> </span><span class="variable declaration injected mutable">foo</span><span class="operator injected">:</span><span class="generic injected"> </span><span class="struct injected">Foo</span><span class="generic injected"> </span><span class="operator injected">=</span><span class="generic injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">;</span><span class="operator injected">
|
||||
</span> <span class="comment documentation">/// ```</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration">new</span><span class="operator">(</span><span class="operator">)</span> <span class="operator">-></span> <span class="struct">Foo</span> <span class="operator">{</span>
|
||||
<span class="struct">Foo</span> <span class="operator">{</span> <span class="field">bar</span><span class="operator">:</span> <span class="bool_literal">true</span> <span class="operator">}</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="comment documentation">/// `bar` method on `Foo`.</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// # Examples</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">use</span><span class="generic injected"> </span><span class="module injected">x</span><span class="generic injected">::</span><span class="module injected">y</span><span class="generic injected">;</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">use</span><span class="generic injected"> </span><span class="module injected">x</span><span class="operator injected">::</span><span class="module injected">y</span><span class="operator injected">;</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">foo</span><span class="generic injected"> = </span><span class="struct injected">Foo</span><span class="generic injected">::</span><span class="function injected">new</span><span class="generic injected">();</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">foo</span><span class="generic injected"> </span><span class="operator injected">=</span><span class="generic injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">;</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// </span><span class="comment injected">// calls bar on foo</span>
|
||||
<span class="comment documentation">/// </span><span class="macro injected">assert!</span><span class="generic injected">(foo.bar());</span>
|
||||
<span class="comment documentation">/// </span><span class="macro injected">assert!</span><span class="operator injected">(</span><span class="generic injected">foo</span><span class="operator injected">.</span><span class="generic injected">bar</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">)</span><span class="operator injected">;</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">bar</span><span class="generic injected"> = </span><span class="variable injected">foo</span><span class="generic injected">.</span><span class="field injected">bar</span><span class="generic injected"> || </span><span class="struct injected">Foo</span><span class="generic injected">::</span><span class="constant injected">bar</span><span class="generic injected">;</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">bar</span><span class="generic injected"> </span><span class="operator injected">=</span><span class="generic injected"> </span><span class="variable injected">foo</span><span class="operator injected">.</span><span class="field injected">bar</span><span class="generic injected"> </span><span class="operator injected">||</span><span class="generic injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="constant injected">bar</span><span class="operator injected">;</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// </span><span class="comment injected">/* multi-line
|
||||
</span><span class="comment documentation">/// </span><span class="comment injected"> comment */</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">multi_line_string</span><span class="generic injected"> = </span><span class="string_literal injected">"Foo
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">multi_line_string</span><span class="generic injected"> </span><span class="operator injected">=</span><span class="generic injected"> </span><span class="string_literal injected">"Foo
|
||||
</span><span class="comment documentation">/// </span><span class="string_literal injected"> bar
|
||||
</span><span class="comment documentation">/// </span><span class="string_literal injected"> "</span><span class="generic injected">;</span>
|
||||
</span><span class="comment documentation">/// </span><span class="string_literal injected"> "</span><span class="operator injected">;</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// ```rust,no_run</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">foobar</span><span class="generic injected"> = </span><span class="struct injected">Foo</span><span class="generic injected">::</span><span class="function injected">new</span><span class="generic injected">().</span><span class="function injected">bar</span><span class="generic injected">();</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">foobar</span><span class="generic injected"> </span><span class="operator injected">=</span><span class="generic injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">.</span><span class="function injected">bar</span><span class="operator injected">(</span><span class="operator injected">)</span><span class="operator injected">;</span><span class="operator injected">
|
||||
</span> <span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// ```sh</span>
|
||||
<span class="comment documentation">/// echo 1</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">foo</span>(&<span class="self_keyword">self</span>) -> <span class="builtin_type">bool</span> {
|
||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">foo</span><span class="operator">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="operator">)</span> <span class="operator">-></span> <span class="builtin_type">bool</span> <span class="operator">{</span>
|
||||
<span class="bool_literal">true</span>
|
||||
}
|
||||
}
|
||||
<span class="operator">}</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">/// </span><span class="macro injected">noop!</span><span class="generic injected">(</span><span class="numeric_literal injected">1</span><span class="generic injected">);</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> {
|
||||
($expr:expr) => {
|
||||
$expr
|
||||
}
|
||||
}</code></pre>
|
||||
<span class="comment documentation">/// </span><span class="macro injected">noop!</span><span class="operator injected">(</span><span class="numeric_literal injected">1</span><span class="operator injected">)</span><span class="operator injected">;</span><span class="operator injected">
|
||||
</span><span class="comment documentation">/// ```</span>
|
||||
<span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> <span class="operator">{</span>
|
||||
<span class="operator">(</span><span class="operator">$</span>expr<span class="operator">:</span>expr<span class="operator">)</span> <span class="operator">=</span><span class="operator">></span> <span class="operator">{</span>
|
||||
<span class="operator">$</span>expr
|
||||
<span class="operator">}</span>
|
||||
<span class="operator">}</span></code></pre>
|
|
@ -35,14 +35,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
|
||||
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
||||
</style>
|
||||
<pre><code><span class="keyword">fn</span> <span class="function declaration">fixture</span>(<span class="value_param declaration">ra_fixture</span>: &<span class="builtin_type">str</span>) {}
|
||||
<pre><code><span class="keyword">fn</span> <span class="function declaration">fixture</span><span class="operator">(</span><span class="value_param declaration">ra_fixture</span><span class="operator">:</span> <span class="operator">&</span><span class="builtin_type">str</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="function">fixture</span>(<span class="string_literal">r#"</span>
|
||||
<span class="keyword">trait</span> <span class="trait declaration">Foo</span> {
|
||||
<span class="keyword">fn</span> <span class="function declaration">foo</span>() {
|
||||
<span class="macro">println!</span>(<span class="string_literal">"2 + 2 = {}"</span>, <span class="numeric_literal">4</span>);
|
||||
}
|
||||
}<span class="string_literal">"#</span>
|
||||
);
|
||||
}</code></pre>
|
||||
<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="function">fixture</span><span class="operator">(</span><span class="string_literal">r#"</span>
|
||||
<span class="keyword">trait</span> <span class="trait declaration">Foo</span> <span class="operator">{</span>
|
||||
<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="operator">(</span><span class="operator">)</span> <span class="operator">{</span>
|
||||
<span class="macro">println!</span><span class="operator">(</span><span class="string_literal">"2 + 2 = {}"</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="operator">}</span><span class="string_literal">"#</span>
|
||||
<span class="operator">)</span><span class="operator">;</span>
|
||||
<span class="operator">}</span></code></pre>
|
|
@ -35,62 +35,62 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
|
||||
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
||||
</style>
|
||||
<pre><code><span class="macro">macro_rules!</span> <span class="macro declaration">println</span> {
|
||||
($($arg:tt)*) => ({
|
||||
$<span class="keyword">crate</span>::io::_print($<span class="keyword">crate</span>::format_args_nl!($($arg)*));
|
||||
})
|
||||
}
|
||||
<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">></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> {
|
||||
($fmt:expr) => {{ <span class="comment">/* compiler built-in */</span> }};
|
||||
($fmt:expr, $($args:tt)*) => {{ <span class="comment">/* compiler built-in */</span> }};
|
||||
}
|
||||
<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">></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">></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="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="string_literal">"Hello"</span>); <span class="comment">// => "Hello"</span>
|
||||
<span class="macro">println!</span>(<span class="string_literal">"Hello, </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"world"</span>); <span class="comment">// => "Hello, world!"</span>
|
||||
<span class="macro">println!</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="numeric_literal">1</span>); <span class="comment">// => "The number is 1"</span>
|
||||
<span class="macro">println!</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="numeric_literal">3</span>, <span class="numeric_literal">4</span>)); <span class="comment">// => "(3, 4)"</span>
|
||||
<span class="macro">println!</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>, value=<span class="numeric_literal">4</span>); <span class="comment">// => "4"</span>
|
||||
<span class="macro">println!</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="numeric_literal">1</span>, <span class="numeric_literal">2</span>); <span class="comment">// => "1 2"</span>
|
||||
<span class="macro">println!</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="numeric_literal">42</span>); <span class="comment">// => "0042" with leading zerosV</span>
|
||||
<span class="macro">println!</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="numeric_literal">1</span>, <span class="numeric_literal">2</span>); <span class="comment">// => "2 1 1 2"</span>
|
||||
<span class="macro">println!</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>, argument = <span class="string_literal">"test"</span>); <span class="comment">// => "test"</span>
|
||||
<span class="macro">println!</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="numeric_literal">1</span>, name = <span class="numeric_literal">2</span>); <span class="comment">// => "2 1"</span>
|
||||
<span class="macro">println!</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>, a=<span class="string_literal">"a"</span>, b=<span class="char_literal">'b'</span>, c=<span class="numeric_literal">3</span>); <span class="comment">// => "a 3 b"</span>
|
||||
<span class="macro">println!</span>(<span class="string_literal">"{{</span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">}}"</span>, <span class="numeric_literal">2</span>); <span class="comment">// => "{2}"</span>
|
||||
<span class="macro">println!</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="string_literal">"x"</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>, <span class="numeric_literal">5</span>);
|
||||
<span class="macro">println!</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="numeric_literal">5</span>, <span class="string_literal">"x"</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>, width = <span class="numeric_literal">5</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>);
|
||||
<span class="macro">println!</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="numeric_literal">5</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"x"</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>);
|
||||
<span class="macro">println!</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="numeric_literal">5</span>);
|
||||
<span class="macro">println!</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="numeric_literal">27</span>);
|
||||
<span class="macro">println!</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="numeric_literal">5</span>);
|
||||
<span class="macro">println!</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="numeric_literal">5</span>);
|
||||
<span class="macro">println!</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="numeric_literal">27</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>, <span class="numeric_literal">0.01</span>);
|
||||
<span class="macro">println!</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="numeric_literal">5</span>, <span class="string_literal">"x"</span>, <span class="numeric_literal">0.01</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>, <span class="numeric_literal">5</span>, <span class="numeric_literal">0.01</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>, <span class="numeric_literal">5</span>, <span class="numeric_literal">0.01</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>, <span class="numeric_literal">5</span>, <span class="numeric_literal">0.01</span>);
|
||||
<span class="macro">println!</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="string_literal">"x"</span>, prec = <span class="numeric_literal">5</span>, number = <span class="numeric_literal">0.01</span>);
|
||||
<span class="macro">println!</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="string_literal">"Hello"</span>, <span class="numeric_literal">3</span>, name=<span class="numeric_literal">1234.56</span>);
|
||||
<span class="macro">println!</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="string_literal">"Hello"</span>, <span class="numeric_literal">3</span>, name=<span class="string_literal">"1234.56"</span>);
|
||||
<span class="macro">println!</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="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="string_literal">"Hello"</span>, <span class="numeric_literal">3</span>, name=<span class="string_literal">"1234.56"</span>);
|
||||
<span class="macro">println!</span>(<span class="string_literal">"Hello {{}}"</span>);
|
||||
<span class="macro">println!</span>(<span class="string_literal">"{{ Hello"</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">// => "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">// => "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">// => "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">// => "(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">// => "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">// => "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">// => "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">// => "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">// => "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">// => "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">// => "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">// => "{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"><</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="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">></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">></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="string_literal">r"Hello, </span><span class="format_specifier">{</span><span class="format_specifier">}</span><span class="string_literal">!"</span>, <span class="string_literal">"world"</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="string_literal">"Hello</span><span class="escape_sequence">\n</span><span class="string_literal">World"</span>);
|
||||
<span class="macro">println!</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="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="string_literal">"</span><span class="format_specifier">{</span><span class="escape_sequence">\x41</span><span class="format_specifier">}</span><span class="string_literal">"</span>, A = <span class="numeric_literal">92</span>);
|
||||
<span class="macro">println!</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="numeric_literal">92</span>);
|
||||
}</code></pre>
|
||||
<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>
|
|
@ -35,20 +35,20 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
|
||||
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
||||
</style>
|
||||
<pre><code><span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_fn</span>() {}
|
||||
<pre><code><span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_fn</span><span class="operator">(</span><span class="operator">)</span> <span class="operator">{</span><span class="operator">}</span>
|
||||
|
||||
<span class="keyword">struct</span> <span class="struct declaration">HasUnsafeFn</span>;
|
||||
<span class="keyword">struct</span> <span class="struct declaration">HasUnsafeFn</span><span class="operator">;</span>
|
||||
|
||||
<span class="keyword">impl</span> <span class="struct">HasUnsafeFn</span> {
|
||||
<span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_method</span>(&<span class="self_keyword">self</span>) {}
|
||||
}
|
||||
<span class="keyword">impl</span> <span class="struct">HasUnsafeFn</span> <span class="operator">{</span>
|
||||
<span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function declaration unsafe">unsafe_method</span><span class="operator">(</span><span class="operator">&</span><span class="self_keyword">self</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="keyword">let</span> <span class="variable declaration">x</span> = &<span class="numeric_literal">5</span> <span class="keyword">as</span> *<span class="keyword">const</span> <span class="builtin_type">usize</span>;
|
||||
<span class="keyword unsafe">unsafe</span> {
|
||||
<span class="function unsafe">unsafe_fn</span>();
|
||||
<span class="struct">HasUnsafeFn</span>.<span class="function unsafe">unsafe_method</span>();
|
||||
<span class="keyword">let</span> <span class="variable declaration">y</span> = <span class="operator unsafe">*</span>(<span class="variable">x</span>);
|
||||
<span class="keyword">let</span> <span class="variable declaration">z</span> = -<span class="variable">x</span>;
|
||||
}
|
||||
}</code></pre>
|
||||
<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="keyword">let</span> <span class="variable declaration">x</span> <span class="operator">=</span> <span class="operator">&</span><span class="numeric_literal">5</span> <span class="keyword">as</span> *<span class="keyword">const</span> <span class="builtin_type">usize</span><span class="operator">;</span>
|
||||
<span class="keyword unsafe">unsafe</span> <span class="operator">{</span>
|
||||
<span class="function unsafe">unsafe_fn</span><span class="operator">(</span><span class="operator">)</span><span class="operator">;</span>
|
||||
<span class="struct">HasUnsafeFn</span><span class="operator">.</span><span class="function unsafe">unsafe_method</span><span class="operator">(</span><span class="operator">)</span><span class="operator">;</span>
|
||||
<span class="keyword">let</span> <span class="variable declaration">y</span> <span class="operator">=</span> <span class="operator unsafe">*</span><span class="operator">(</span><span class="variable">x</span><span class="operator">)</span><span class="operator">;</span>
|
||||
<span class="keyword">let</span> <span class="variable declaration">z</span> <span class="operator">=</span> <span class="operator">-</span><span class="variable">x</span><span class="operator">;</span>
|
||||
<span class="operator">}</span>
|
||||
<span class="operator">}</span></code></pre>
|
|
@ -35,94 +35,94 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
|
||||
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
||||
</style>
|
||||
<pre><code><span class="attribute">#[</span><span class="function attribute">derive</span><span class="attribute">(Clone, Debug)]</span>
|
||||
<span class="keyword">struct</span> <span class="struct declaration">Foo</span> {
|
||||
<span class="keyword">pub</span> <span class="field declaration">x</span>: <span class="builtin_type">i32</span>,
|
||||
<span class="keyword">pub</span> <span class="field declaration">y</span>: <span class="builtin_type">i32</span>,
|
||||
}
|
||||
<pre><code><span class="operator">#</span><span class="operator">[</span><span class="function attribute">derive</span><span class="operator">(</span><span class="attribute">Clone</span><span class="operator">,</span><span class="attribute"> Debug</span><span class="operator">)</span><span class="operator">]</span>
|
||||
<span class="keyword">struct</span> <span class="struct declaration">Foo</span> <span class="operator">{</span>
|
||||
<span class="keyword">pub</span> <span class="field declaration">x</span><span class="operator">:</span> <span class="builtin_type">i32</span><span class="operator">,</span>
|
||||
<span class="keyword">pub</span> <span class="field declaration">y</span><span class="operator">:</span> <span class="builtin_type">i32</span><span class="operator">,</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="keyword">trait</span> <span class="trait declaration">Bar</span> {
|
||||
<span class="keyword">fn</span> <span class="function declaration">bar</span>(&<span class="self_keyword">self</span>) -> <span class="builtin_type">i32</span>;
|
||||
}
|
||||
<span class="keyword">trait</span> <span class="trait declaration">Bar</span> <span class="operator">{</span>
|
||||
<span class="keyword">fn</span> <span class="function declaration">bar</span><span class="operator">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="operator">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span><span class="operator">;</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="keyword">impl</span> <span class="trait">Bar</span> <span class="keyword">for</span> <span class="struct">Foo</span> {
|
||||
<span class="keyword">fn</span> <span class="function declaration">bar</span>(&<span class="self_keyword">self</span>) -> <span class="builtin_type">i32</span> {
|
||||
<span class="self_keyword">self</span>.<span class="field">x</span>
|
||||
}
|
||||
}
|
||||
<span class="keyword">impl</span> <span class="trait">Bar</span> <span class="keyword">for</span> <span class="struct">Foo</span> <span class="operator">{</span>
|
||||
<span class="keyword">fn</span> <span class="function declaration">bar</span><span class="operator">(</span><span class="operator">&</span><span class="self_keyword">self</span><span class="operator">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="operator">{</span>
|
||||
<span class="self_keyword">self</span><span class="operator">.</span><span class="field">x</span>
|
||||
<span class="operator">}</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="keyword">impl</span> <span class="struct">Foo</span> {
|
||||
<span class="keyword">fn</span> <span class="function declaration">baz</span>(<span class="keyword">mut</span> <span class="self_keyword mutable">self</span>) -> <span class="builtin_type">i32</span> {
|
||||
<span class="self_keyword">self</span>.<span class="field">x</span>
|
||||
}
|
||||
<span class="keyword">impl</span> <span class="struct">Foo</span> <span class="operator">{</span>
|
||||
<span class="keyword">fn</span> <span class="function declaration">baz</span><span class="operator">(</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="operator">)</span> <span class="operator">-></span> <span class="builtin_type">i32</span> <span class="operator">{</span>
|
||||
<span class="self_keyword">self</span><span class="operator">.</span><span class="field">x</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="keyword">fn</span> <span class="function declaration">qux</span>(&<span class="keyword">mut</span> <span class="self_keyword mutable">self</span>) {
|
||||
<span class="self_keyword mutable">self</span>.<span class="field">x</span> = <span class="numeric_literal">0</span>;
|
||||
}
|
||||
}
|
||||
<span class="keyword">fn</span> <span class="function declaration">qux</span><span class="operator">(</span><span class="operator">&</span><span class="keyword">mut</span> <span class="self_keyword mutable">self</span><span class="operator">)</span> <span class="operator">{</span>
|
||||
<span class="self_keyword mutable">self</span><span class="operator">.</span><span class="field">x</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="operator">;</span>
|
||||
<span class="operator">}</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable">STATIC_MUT</span>: <span class="builtin_type">i32</span> = <span class="numeric_literal">0</span>;
|
||||
<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable">STATIC_MUT</span><span class="operator">:</span> <span class="builtin_type">i32</span> <span class="operator">=</span> <span class="numeric_literal">0</span><span class="operator">;</span>
|
||||
|
||||
<span class="keyword">fn</span> <span class="function declaration">foo</span><<span class="lifetime declaration">'a</span>, <span class="type_param declaration">T</span>>() -> <span class="type_param">T</span> {
|
||||
<span class="function">foo</span>::<<span class="lifetime">'a</span>, <span class="builtin_type">i32</span>>()
|
||||
}
|
||||
<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="operator"><</span><span class="lifetime declaration">'a</span><span class="operator">,</span> <span class="type_param declaration">T</span><span class="operator">></span><span class="operator">(</span><span class="operator">)</span> <span class="operator">-></span> <span class="type_param">T</span> <span class="operator">{</span>
|
||||
<span class="function">foo</span><span class="operator">::</span><span class="operator"><</span><span class="lifetime">'a</span><span class="operator">,</span> <span class="builtin_type">i32</span><span class="operator">></span><span class="operator">(</span><span class="operator">)</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="macro">macro_rules!</span> <span class="macro declaration">def_fn</span> {
|
||||
($($tt:tt)*) => {$($tt)*}
|
||||
}
|
||||
<span class="macro">macro_rules!</span> <span class="macro declaration">def_fn</span> <span class="operator">{</span>
|
||||
<span class="operator">(</span><span class="operator">$</span><span class="operator">(</span><span class="operator">$</span>tt<span class="operator">:</span>tt<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><span class="operator">$</span>tt<span class="operator">)</span>*<span class="operator">}</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="macro">def_fn!</span> {
|
||||
<span class="keyword">fn</span> <span class="function declaration">bar</span>() -> <span class="builtin_type">u32</span> {
|
||||
<span class="macro">def_fn!</span> <span class="operator">{</span>
|
||||
<span class="keyword">fn</span> <span class="function declaration">bar</span><span class="operator">(</span><span class="operator">)</span> <span class="operator">-</span><span class="operator">></span> <span class="builtin_type">u32</span> <span class="operator">{</span>
|
||||
<span class="numeric_literal">100</span>
|
||||
}
|
||||
}
|
||||
<span class="operator">}</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> {
|
||||
($expr:expr) => {
|
||||
$expr
|
||||
}
|
||||
}
|
||||
<span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> <span class="operator">{</span>
|
||||
<span class="operator">(</span><span class="operator">$</span>expr<span class="operator">:</span>expr<span class="operator">)</span> <span class="operator">=</span><span class="operator">></span> <span class="operator">{</span>
|
||||
<span class="operator">$</span>expr
|
||||
<span class="operator">}</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="comment">// comment</span>
|
||||
<span class="keyword">fn</span> <span class="function declaration">main</span>() {
|
||||
<span class="macro">println!</span>(<span class="string_literal">"Hello, {}!"</span>, <span class="numeric_literal">92</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="macro">println!</span><span class="operator">(</span><span class="string_literal">"Hello, {}!"</span><span class="operator">,</span> <span class="numeric_literal">92</span><span class="operator">)</span><span class="operator">;</span>
|
||||
|
||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">vec</span> = <span class="unresolved_reference">Vec</span>::<span class="unresolved_reference">new</span>();
|
||||
<span class="keyword control">if</span> <span class="bool_literal">true</span> {
|
||||
<span class="keyword">let</span> <span class="variable declaration">x</span> = <span class="numeric_literal">92</span>;
|
||||
<span class="variable mutable">vec</span>.<span class="unresolved_reference">push</span>(<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>.<span class="unresolved_reference">set_len</span>(<span class="numeric_literal">0</span>);
|
||||
<span class="static mutable">STATIC_MUT</span> = <span class="numeric_literal">1</span>;
|
||||
}
|
||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">vec</span> <span class="operator">=</span> <span class="unresolved_reference">Vec</span><span class="operator">::</span><span class="unresolved_reference">new</span><span class="operator">(</span><span class="operator">)</span><span class="operator">;</span>
|
||||
<span class="keyword control">if</span> <span class="bool_literal">true</span> <span class="operator">{</span>
|
||||
<span class="keyword">let</span> <span class="variable declaration">x</span> <span class="operator">=</span> <span class="numeric_literal">92</span><span class="operator">;</span>
|
||||
<span class="variable mutable">vec</span><span class="operator">.</span><span class="unresolved_reference">push</span><span class="operator">(</span><span class="struct">Foo</span> <span class="operator">{</span> <span class="field">x</span><span class="operator">,</span> <span class="field">y</span><span class="operator">:</span> <span class="numeric_literal">1</span> <span class="operator">}</span><span class="operator">)</span><span class="operator">;</span>
|
||||
<span class="operator">}</span>
|
||||
<span class="keyword unsafe">unsafe</span> <span class="operator">{</span>
|
||||
<span class="variable mutable">vec</span><span class="operator">.</span><span class="unresolved_reference">set_len</span><span class="operator">(</span><span class="numeric_literal">0</span><span class="operator">)</span><span class="operator">;</span>
|
||||
<span class="static mutable">STATIC_MUT</span> <span class="operator">=</span> <span class="numeric_literal">1</span><span class="operator">;</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="keyword control">for</span> <span class="variable declaration">e</span> <span class="keyword control">in</span> <span class="variable mutable">vec</span> {
|
||||
<span class="keyword control">for</span> <span class="variable declaration">e</span> <span class="keyword control">in</span> <span class="variable mutable">vec</span> <span class="operator">{</span>
|
||||
<span class="comment">// Do nothing</span>
|
||||
}
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="macro">noop!</span>(<span class="macro">noop</span><span class="macro">!</span>(<span class="numeric_literal">1</span>));
|
||||
<span class="macro">noop!</span><span class="operator">(</span><span class="macro">noop</span><span class="macro">!</span><span class="operator">(</span><span class="numeric_literal">1</span><span class="operator">)</span><span class="operator">)</span><span class="operator">;</span>
|
||||
|
||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">x</span> = <span class="numeric_literal">42</span>;
|
||||
<span class="keyword">let</span> <span class="variable declaration mutable">y</span> = &<span class="keyword">mut</span> <span class="variable mutable">x</span>;
|
||||
<span class="keyword">let</span> <span class="variable declaration">z</span> = &<span class="variable mutable">y</span>;
|
||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">x</span> <span class="operator">=</span> <span class="numeric_literal">42</span><span class="operator">;</span>
|
||||
<span class="keyword">let</span> <span class="variable declaration mutable">y</span> <span class="operator">=</span> <span class="operator">&</span><span class="keyword">mut</span> <span class="variable mutable">x</span><span class="operator">;</span>
|
||||
<span class="keyword">let</span> <span class="variable declaration">z</span> <span class="operator">=</span> <span class="operator">&</span><span class="variable mutable">y</span><span class="operator">;</span>
|
||||
|
||||
<span class="keyword">let</span> <span class="struct">Foo</span> { <span class="field">x</span>: <span class="variable declaration">z</span>, <span class="field">y</span> } = <span class="struct">Foo</span> { <span class="field">x</span>: <span class="variable">z</span>, <span class="field">y</span> };
|
||||
<span class="keyword">let</span> <span class="struct">Foo</span> <span class="operator">{</span> <span class="field">x</span><span class="operator">:</span> <span class="variable declaration">z</span><span class="operator">,</span> <span class="field">y</span> <span class="operator">}</span> <span class="operator">=</span> <span class="struct">Foo</span> <span class="operator">{</span> <span class="field">x</span><span class="operator">:</span> <span class="variable">z</span><span class="operator">,</span> <span class="field">y</span> <span class="operator">}</span><span class="operator">;</span>
|
||||
|
||||
<span class="variable">y</span>;
|
||||
}
|
||||
<span class="variable">y</span><span class="operator">;</span>
|
||||
<span class="operator">}</span>
|
||||
|
||||
<span class="keyword">enum</span> <span class="enum declaration">Option</span><<span class="type_param declaration">T</span>> {
|
||||
<span class="enum_variant declaration">Some</span>(<span class="type_param">T</span>),
|
||||
<span class="enum_variant declaration">None</span>,
|
||||
}
|
||||
<span class="keyword">use</span> <span class="enum">Option</span>::*;
|
||||
<span class="keyword">enum</span> <span class="enum declaration">Option</span><span class="operator"><</span><span class="type_param declaration">T</span><span class="operator">></span> <span class="operator">{</span>
|
||||
<span class="enum_variant declaration">Some</span><span class="operator">(</span><span class="type_param">T</span><span class="operator">)</span><span class="operator">,</span>
|
||||
<span class="enum_variant declaration">None</span><span class="operator">,</span>
|
||||
<span class="operator">}</span>
|
||||
<span class="keyword">use</span> <span class="enum">Option</span><span class="operator">::</span>*<span class="operator">;</span>
|
||||
|
||||
<span class="keyword">impl</span><<span class="type_param declaration">T</span>> <span class="enum">Option</span><<span class="type_param">T</span>> {
|
||||
<span class="keyword">fn</span> <span class="function declaration">and</span><<span class="type_param declaration">U</span>>(<span class="self_keyword">self</span>, <span class="value_param declaration">other</span>: <span class="enum">Option</span><<span class="type_param">U</span>>) -> <span class="enum">Option</span><(<span class="type_param">T</span>, <span class="type_param">U</span>)> {
|
||||
<span class="keyword control">match</span> <span class="value_param">other</span> {
|
||||
<span class="enum_variant">None</span> => <span class="macro">unimplemented!</span>(),
|
||||
<span class="variable declaration">Nope</span> => <span class="variable">Nope</span>,
|
||||
}
|
||||
}
|
||||
}</code></pre>
|
||||
<span class="keyword">impl</span><span class="operator"><</span><span class="type_param declaration">T</span><span class="operator">></span> <span class="enum">Option</span><span class="operator"><</span><span class="type_param">T</span><span class="operator">></span> <span class="operator">{</span>
|
||||
<span class="keyword">fn</span> <span class="function declaration">and</span><span class="operator"><</span><span class="type_param declaration">U</span><span class="operator">></span><span class="operator">(</span><span class="self_keyword">self</span><span class="operator">,</span> <span class="value_param declaration">other</span><span class="operator">:</span> <span class="enum">Option</span><span class="operator"><</span><span class="type_param">U</span><span class="operator">></span><span class="operator">)</span> <span class="operator">-></span> <span class="enum">Option</span><span class="operator"><</span><span class="operator">(</span><span class="type_param">T</span><span class="operator">,</span> <span class="type_param">U</span><span class="operator">)</span><span class="operator">></span> <span class="operator">{</span>
|
||||
<span class="keyword control">match</span> <span class="value_param">other</span> <span class="operator">{</span>
|
||||
<span class="enum_variant">None</span> <span class="operator">=></span> <span class="macro">unimplemented!</span><span class="operator">(</span><span class="operator">)</span><span class="operator">,</span>
|
||||
<span class="variable declaration">Nope</span> <span class="operator">=></span> <span class="variable">Nope</span><span class="operator">,</span>
|
||||
<span class="operator">}</span>
|
||||
<span class="operator">}</span>
|
||||
<span class="operator">}</span></code></pre>
|
|
@ -35,15 +35,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
|
||||
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
||||
</style>
|
||||
<pre><code><span class="keyword">fn</span> <span class="function declaration">main</span>() {
|
||||
<span class="keyword">let</span> <span class="variable declaration" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> = <span class="string_literal">"hello"</span>;
|
||||
<span class="keyword">let</span> <span class="variable declaration" data-binding-hash="2705725358298919760" style="color: hsl(17,51%,74%);">x</span> = <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span>.<span class="unresolved_reference">to_string</span>();
|
||||
<span class="keyword">let</span> <span class="variable declaration" data-binding-hash="3365759661443752373" style="color: hsl(127,76%,66%);">y</span> = <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span>.<span class="unresolved_reference">to_string</span>();
|
||||
<pre><code><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="keyword">let</span> <span class="variable declaration" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> <span class="operator">=</span> <span class="string_literal">"hello"</span><span class="operator">;</span>
|
||||
<span class="keyword">let</span> <span class="variable declaration" data-binding-hash="2705725358298919760" style="color: hsl(17,51%,74%);">x</span> <span class="operator">=</span> <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span><span class="operator">.</span><span class="unresolved_reference">to_string</span><span class="operator">(</span><span class="operator">)</span><span class="operator">;</span>
|
||||
<span class="keyword">let</span> <span class="variable declaration" data-binding-hash="3365759661443752373" style="color: hsl(127,76%,66%);">y</span> <span class="operator">=</span> <span class="variable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span><span class="operator">.</span><span class="unresolved_reference">to_string</span><span class="operator">(</span><span class="operator">)</span><span class="operator">;</span>
|
||||
|
||||
<span class="keyword">let</span> <span class="variable declaration" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span> = <span class="string_literal">"other color please!"</span>;
|
||||
<span class="keyword">let</span> <span class="variable declaration" data-binding-hash="6717528807933952652" style="color: hsl(85,49%,84%);">y</span> = <span class="variable" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span>.<span class="unresolved_reference">to_string</span>();
|
||||
}
|
||||
<span class="keyword">let</span> <span class="variable declaration" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span> <span class="operator">=</span> <span class="string_literal">"other color please!"</span><span class="operator">;</span>
|
||||
<span class="keyword">let</span> <span class="variable declaration" data-binding-hash="6717528807933952652" style="color: hsl(85,49%,84%);">y</span> <span class="operator">=</span> <span class="variable" data-binding-hash="794745962933817518" style="color: hsl(19,74%,76%);">x</span><span class="operator">.</span><span class="unresolved_reference">to_string</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">bar</span>() {
|
||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> = <span class="string_literal">"hello"</span>;
|
||||
}</code></pre>
|
||||
<span class="keyword">fn</span> <span class="function declaration">bar</span><span class="operator">(</span><span class="operator">)</span> <span class="operator">{</span>
|
||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable" data-binding-hash="8121853618659664005" style="color: hsl(261,57%,61%);">hello</span> <span class="operator">=</span> <span class="string_literal">"hello"</span><span class="operator">;</span>
|
||||
<span class="operator">}</span></code></pre>
|
Loading…
Reference in a new issue