rust-ape-example/src/bin/error_abort_unwind.rs
2022-09-07 11:36:05 +05:30

40 lines
794 B
Rust

// ./src/error/abort_unwind.md
/*
fn drink(beverage: &str) {
// You shouldn't drink too much sugary beverages.
if beverage == "lemonade" {
if cfg!(panic="abort"){ println!("This is not your party. Run!!!!");}
else{ println!("Spit it out!!!!");}
}
else{ println!("Some refreshing {} is all I need.", beverage); }
}
fn part0() {
drink("water");
drink("lemonade");
}
*/
#[cfg(panic = "unwind")]
fn ah(){ println!("Spit it out!!!!");}
#[cfg(not(panic="unwind"))]
fn ah(){ println!("This is not your party. Run!!!!");}
fn drink(beverage: &str){
if beverage == "lemonade"{ ah();}
else{println!("Some refreshing {} is all I need.", beverage);}
}
fn part1() {
drink("water");
drink("lemonade");
}
pub fn main() {
// part0();
part1();
}