Code: Select all
//this function never exits
fn panic() -> ! {
...
}
Code: Select all
let opt = Some(10);
let value: i32 = match opt {
Some(v) => v,
None => panic!("it crashed"); // ! is converted to i32, as in this branch we never return anyway
};
Code: Select all
let x = foo(return 5);
Code: Select all
let x = match value {
Some(v) => v,
None => return None,
};
Code: Select all
=> { return None; }
Code: Select all
fn zombiejesus() {
loop {
while (return) {
if (return) {
match (return) {
1 => {
if (return) {
return
} else {
return
}
}
_ => { return }
};
} else if (return) {
return;
}
}
if (return) { break; }
}
}
Code: Select all
let x = {
{ return; };
5
};
Code: Select all
//this function never exits
fn panic() -> ! {
...
}
Code: Select all
let opt = Some(10);
let value: i32 = match opt {
Some(v) => v,
None => panic!("it crashed"); // ! is converted to i32, as in this branch we never return anyway
};
Code: Select all
let x = foo(return 5);
Code: Select all
let x = match value {
Some(v) => v,
None => return None,
};
Code: Select all
=> { return None; }
Code: Select all
fn zombiejesus() {
loop {
while (return) {
if (return) {
match (return) {
1 => {
if (return) {
return
} else {
return
}
}
_ => { return }
};
} else if (return) {
return;
}
}
if (return) { break; }
}
}
Code: Select all
let x = {
{ return; };
5
};