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

Commit 6a3e70b

Browse files
authored
Merge pull request #756 from nubark/feat/simpler_welcoming_example
Change example.rs to a simpler and more welcoming one
2 parents 7320ff4 + 8a6373e commit 6a3e70b

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

_includes/example.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
// This code is editable and runnable!
22
fn main() {
3-
// A simple integer calculator:
4-
// `+` or `-` means add or subtract by 1
5-
// `*` or `/` means multiply or divide by 2
3+
let greetings = ["Hello", "Hola", "こんにちは", "您好"];
64

7-
let program = "+ + * - /";
8-
let mut accumulator = 0;
9-
10-
for token in program.chars() {
11-
match token {
12-
'+' => accumulator += 1,
13-
'-' => accumulator -= 1,
14-
'*' => accumulator *= 2,
15-
'/' => accumulator /= 2,
16-
_ => { /* ignore everything else */ }
17-
}
5+
for greeting in greetings.iter() {
6+
println!("{}", greeting);
187
}
19-
20-
println!("The program \"{}\" calculates the value {}",
21-
program, accumulator);
228
}

0 commit comments

Comments
 (0)