Introduction
In this lab, you will learn about the concept of returning from loops in Rust, which involves retrying an operation until it succeeds and passing the resulting value to the rest of the code by placing it after the break
statement within the loop
expression.
Note: If the lab does not specify a file name, you can use any file name you want. For example, you can use main.rs
, compile and run it with rustc main.rs && ./main
.
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
rust(("`Rust`")) -.-> rust/BasicConceptsGroup(["`Basic Concepts`"])
rust(("`Rust`")) -.-> rust/FunctionsandClosuresGroup(["`Functions and Closures`"])
rust/BasicConceptsGroup -.-> rust/variable_declarations("`Variable Declarations`")
rust/BasicConceptsGroup -.-> rust/mutable_variables("`Mutable Variables`")
rust/FunctionsandClosuresGroup -.-> rust/function_syntax("`Function Syntax`")
rust/FunctionsandClosuresGroup -.-> rust/expressions_statements("`Expressions and Statements`")
subgraph Lab Skills
rust/variable_declarations -.-> lab-99306{{"`Returning From Loops`"}}
rust/mutable_variables -.-> lab-99306{{"`Returning From Loops`"}}
rust/function_syntax -.-> lab-99306{{"`Returning From Loops`"}}
rust/expressions_statements -.-> lab-99306{{"`Returning From Loops`"}}
end