Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit eebd915

Browse files
authored
Merge pull request #776 from brson/ex
Example cleanup
2 parents 5b7c0e7 + 24c0cec commit eebd915

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

_includes/example.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
fn main() {
22
let greetings = ["Hello", "Hola", "Bonjour",
3-
"こんにちは", "您好"];
4-
5-
for (num,greeting) in greetings.iter().enumerate() {
3+
"こんにちは", "您好"];
4+
5+
for (num,greeting) in greetings.iter().enumerate() {
66
println!("{}", greeting);
77
match num {
88
0 => println!("This code is editable and runnable!"),

_includes/example.rs.html

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
<pre class='rust'>
22
<span class='kw'>fn</span> main() {
3-
<span class='comment'>// A simple integer calculator:
4-
// `+` or `-` means add or subtract by 1
5-
// `*` or `/` means multiply or divide by 2</span>
3+
<span class='kw'>let</span> greetings = [<span class='string'>"Hello"</span>, <span class='string'>"Hola"<span>, <span class='string'>"Bonjour"</span>,
4+
<span class='string'>"こんにちは"</span>, <span class='string'>"您好"</span>];
65

7-
<span class='kw'>let</span> program = <span class='string'>"+ + * - /"</span>;
8-
<span class='kw'>let</span> <span class='kw'>mut</span> accumulator = <span class='number'>0</span>;
9-
10-
<span class='kw'>for</span> token in program.chars() {
11-
<span class='kw'>match</span> token {
12-
<span class='string'>'+'</span> => accumulator <span class='op'>+=</span> <span class='number'>1</span>,
13-
<span class='string'>'-'</span> => accumulator <span class='op'>-=</span> <span class='number'>1</span>,
14-
<span class='string'>'*'</span> => accumulator <span class='op'>*=</span> <span class='number'>2</span>,
15-
<span class='string'>'/'</span> => accumulator <span class='op'>/=</span> <span class='number'>2</span>,
16-
_ => { <span class='comment'>/* ignore everything else */</span> }
17-
}
18-
}
19-
20-
<span class='prelude-val'>println!</span>(<span class='string'>"The program \"{}\" calculates the value {}"</span>,
21-
program, accumulator);
6+
<span class='kw'>for</span> (num,greeting) in greetings.iter().enumerate() {
7+
<span class='prelude-val'>println!</span>(<span class='string'>"{}"</span>, greeting);
8+
<span class='kw'>match</span> num {
9+
0 => <span class='prelude-val'>println!</span>(<span class='string'>"This code is editable and runnable!"</span>),
10+
1 => <span class='prelude-val'>println!</span>(<span class='string'>"Este código es editable y ejecutable!"</span>),
11+
2 => <span class='prelude-val'>println!</span>(<span class='string'>"Ce code est modifiable et exécutable!"</span>),
12+
3 => <span class='prelude-val'>println!</span>(<span class='string'>"このコードは編集して実行出来ます!"</span>),
13+
4 => <span class='prelude-val'>println!</span>(<span class='string'>"这个代码是可以编辑并且能够运行的!"</span>),
14+
_ => {},
15+
}
16+
}
2217
}
2318
</pre>

css/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,14 @@ ul.laundry-list {
246246
padding: none;
247247
margin: none;
248248
width: 100%;
249-
min-height: 340px;
249+
min-height: 300px;
250250
font-size: 13px;
251251
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
252252
white-space: pre-wrap;
253253
}
254254

255255
#active-code {
256+
margin-top: 1rem;
256257
position: relative;
257258
display: none;
258259
padding: 10px;

0 commit comments

Comments
 (0)