forked from inancgumus/learnrust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
51 lines (40 loc) · 1.75 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
#1: defines a function named: `main`.
main function:
+ this is a special function.
+ it runs as the first code in an executable rust program.
*/
fn main() {
/* ^
|
between `{` and `}`
this is where this function's body starts.
=========================================================
COMPILING & RUNNING THIS PROGRAM:
=========================================================
what you write in the function body will be executed,
1. when you compile:
rustc main.rs
2. and run on xnix:
./main
3. or run on windows:
.\main.exe
*/
println!("Hello, world!");
// ^ ^
/* | +--------------------------------------------------------+
| |
#3: calls a macro named: `println` that writes "Hello, world!" to the screen. |
|
+ to call a macro : println!("...") |
+ to call a function: println("...") |
+ you'll learn the differences later on. |
|
|
end your statements with this semicolon. <----------------------------------------+
so the next one can begin.
why?
just like in C, and other languages with a similar syntax,
semicolon here tells the compiler that this statement is over.
*/
}