rust-ape-example/src/bin/error_abort_unwind.rs

41 lines
794 B
Rust
Raw Normal View History

// ./src/error/abort_unwind.md
2022-09-07 05:36:14 +00:00
/*
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");
}
2022-09-07 05:36:14 +00:00
*/
#[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() {
2022-09-07 05:36:14 +00:00
// part0();
part1();
}