feat: divergin functions understood

This commit is contained in:
2025-01-04 00:44:42 +01:00
parent d5a66a151b
commit 2318258718
2 changed files with 19 additions and 4 deletions

View File

@@ -63,6 +63,10 @@ fn create_fn() -> impl Fn() {
// value;
}
fn divergin_one() -> ! {
panic!("This will never return! PANIC");
}
pub fn functions_module() {
fizzbuzz(10);
@@ -99,4 +103,15 @@ pub fn functions_module() {
// Diverging functions
// 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();
}