mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 15:43:58 +00:00
The source code can be run by Rust Playground
The source code can be run by Rust Playground without warnings
This commit is contained in:
parent
42a4294151
commit
cd6abe0bfc
@ -41,6 +41,7 @@ Rust not only fast, but also easy and efficient to code in.
|
|||||||
// 1. Basics //
|
// 1. Basics //
|
||||||
///////////////
|
///////////////
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
// Functions
|
// Functions
|
||||||
// `i32` is the type for 32-bit signed integers
|
// `i32` is the type for 32-bit signed integers
|
||||||
fn add2(x: i32, y: i32) -> i32 {
|
fn add2(x: i32, y: i32) -> i32 {
|
||||||
@ -48,6 +49,9 @@ fn add2(x: i32, y: i32) -> i32 {
|
|||||||
x + y
|
x + y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
#[allow(unused_assignments)]
|
||||||
|
#[allow(dead_code)]
|
||||||
// Main function
|
// Main function
|
||||||
fn main() {
|
fn main() {
|
||||||
// Numbers //
|
// Numbers //
|
||||||
@ -256,11 +260,13 @@ fn main() {
|
|||||||
// `while` loop
|
// `while` loop
|
||||||
while 1 == 1 {
|
while 1 == 1 {
|
||||||
println!("The universe is operating normally.");
|
println!("The universe is operating normally.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infinite loop
|
// Infinite loop
|
||||||
loop {
|
loop {
|
||||||
println!("Hello!");
|
println!("Hello!");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user