mirror of
https://github.com/ahgamut/rust-ape-example.git
synced 2024-11-25 01:01:01 +00:00
40 lines
794 B
Rust
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();
|
|
}
|
|
|