From 29cc9e92c3d5724bbc94e70be07ca77b75b7fdd4 Mon Sep 17 00:00:00 2001 From: sunface Date: Thu, 10 Mar 2022 16:22:33 +0800 Subject: [PATCH] add solutions for panic.md --- solutions/result-panic/panic.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/solutions/result-panic/panic.md b/solutions/result-panic/panic.md index a8edccb..af6118a 100644 --- a/solutions/result-panic/panic.md +++ b/solutions/result-panic/panic.md @@ -1,3 +1,23 @@ +1. +```rust +use core::panic; + +fn drink(beverage: &str) { + if beverage == "lemonade" { + println!("Success!"); + // IMPLEMENT the below code + panic!("drinked, duang.....peng!") + } + + println!("Excercise Failed if printing out this line!"); +} + +fn main() { + drink("lemonade"); + + println!("Excercise Failed if printing out this line!"); +} +``` 2. ```rust