From cd6abe0bfcf6f34cec65b12324cebee666e0a19a Mon Sep 17 00:00:00 2001 From: Anatolij Date: Thu, 20 Sep 2018 09:19:39 +0200 Subject: The source code can be run by Rust Playground The source code can be run by Rust Playground without warnings --- rust.html.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rust.html.markdown b/rust.html.markdown index 6b75fa87..1c0e324c 100644 --- a/rust.html.markdown +++ b/rust.html.markdown @@ -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,13 @@ fn main() { // `while` loop while 1 == 1 { println!("The universe is operating normally."); + break; } // Infinite loop loop { println!("Hello!"); + break; } ///////////////////////////////// -- cgit v1.2.3 From 501828c89180d88183aa05749911f4e660878c23 Mon Sep 17 00:00:00 2001 From: Anatolij Date: Thu, 20 Sep 2018 13:04:31 +0200 Subject: Add gescription related break statement Insert description related to break statement. --- rust.html.markdown | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rust.html.markdown b/rust.html.markdown index 1c0e324c..71bc16b5 100644 --- a/rust.html.markdown +++ b/rust.html.markdown @@ -260,13 +260,16 @@ fn main() { // `while` loop while 1 == 1 { println!("The universe is operating normally."); - break; + // break statement gets out of the while loop. + // It avoids useless iterations. + break } // Infinite loop loop { println!("Hello!"); - break; + // break statement gets out of the loop + break } ///////////////////////////////// -- cgit v1.2.3