0% found this document useful (0 votes)
23 views

Hello World - Rust by Example

Uploaded by

Vladimír Pilát
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Hello World - Rust by Example

Uploaded by

Vladimír Pilát
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Hello World - Rust By Example 09.10.

2023 12:47

Hello World
This is the source code of the traditional Hello World program.

1 // This is a comment, and is ignored by the compiler.


2 // You can test this code by clicking the "Run" button over there ->
3 // or if you prefer to use your keyboard, you can use the "Ctrl + Enter"
4 // shortcut.
5
6 // This code is editable, feel free to hack it!
7 // You can always return to the original code by clicking the "Reset" button -
8
9 // This is the main function.
10 fn main() {
11 // Statements here are executed when the compiled binary is called.
12
13 // Print text to the console.
14 println!("Hello World!");
15 }

println! is a macro that prints text to the console.

A binary can be generated using the Rust compiler: rustc .

$ rustc hello.rs

rustc will produce a hello binary that can be executed.

$ ./hello
Hello World!

Activity

Click 'Run' above to see the expected output. Next, add a new line with a second
println! macro so that the output shows:

Hello World!
I'm a Rustacean!

https://doc.rust-lang.org/rust-by-example/hello.html Stránka 1 z 1

You might also like