feat: divergin functions understood
This commit is contained in:
@@ -63,6 +63,10 @@ fn create_fn() -> impl Fn() {
|
|||||||
// value;
|
// value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn divergin_one() -> ! {
|
||||||
|
panic!("This will never return! PANIC");
|
||||||
|
}
|
||||||
|
|
||||||
pub fn functions_module() {
|
pub fn functions_module() {
|
||||||
fizzbuzz(10);
|
fizzbuzz(10);
|
||||||
|
|
||||||
@@ -99,4 +103,15 @@ pub fn functions_module() {
|
|||||||
|
|
||||||
// Diverging functions
|
// Diverging functions
|
||||||
// Never return, marked with: !
|
// Never return, marked with: !
|
||||||
|
// Useful on divergin situations where an exact type is required
|
||||||
|
for i in 0..5 {
|
||||||
|
let value: u32 = match i % 2 == 0 {
|
||||||
|
true => 5,
|
||||||
|
false => continue,
|
||||||
|
};
|
||||||
|
println!("The value is pair and {value}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Bad example since it's not really useful
|
||||||
|
divergin_one();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
// mod controlflow;
|
// mod controlflow;
|
||||||
// mod traits;
|
// mod traits;
|
||||||
// mod str_types;
|
// mod str_types;
|
||||||
// mod functions;
|
mod functions;
|
||||||
mod exercises;
|
// mod exercises;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// helloworld::hello_world_module();
|
// helloworld::hello_world_module();
|
||||||
@@ -27,6 +27,6 @@ fn main() {
|
|||||||
// controlflow::control_flow_module();
|
// controlflow::control_flow_module();
|
||||||
//traits::traits_exercise();
|
//traits::traits_exercise();
|
||||||
// str_types::str_types_module();
|
// str_types::str_types_module();
|
||||||
// functions::functions_module();
|
functions::functions_module();
|
||||||
exercises::run_easy();
|
// exercises::run_easy();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user