mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Merge pull request #3224 from java1cprog/patch-1
The source code can be run by Rust Playground
This commit is contained in:
commit
b1e24fffcb
@ -41,6 +41,7 @@ Rust not only fast, but also easy and efficient to code in.
|
||||
// 1. Basics //
|
||||
///////////////
|
||||
|
||||
#[allow(dead_code)]
|
||||
// Functions
|
||||
// `i32` is the type for 32-bit signed integers
|
||||
fn add2(x: i32, y: i32) -> i32 {
|
||||
@ -48,6 +49,9 @@ fn add2(x: i32, y: i32) -> i32 {
|
||||
x + y
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[allow(unused_assignments)]
|
||||
#[allow(dead_code)]
|
||||
// Main function
|
||||
fn main() {
|
||||
// Numbers //
|
||||
@ -256,11 +260,16 @@ fn main() {
|
||||
// `while` loop
|
||||
while 1 == 1 {
|
||||
println!("The universe is operating normally.");
|
||||
// break statement gets out of the while loop.
|
||||
// It avoids useless iterations.
|
||||
break
|
||||
}
|
||||
|
||||
// Infinite loop
|
||||
loop {
|
||||
println!("Hello!");
|
||||
// break statement gets out of the loop
|
||||
break
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user