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