From a17977de9b36fb11f03af852a515217423ef21ad Mon Sep 17 00:00:00 2001 From: nprimo Date: Fri, 18 Nov 2022 09:37:13 +0000 Subject: [PATCH] feat(prime_checker): simplify example main --- subjects/prime_checker/README.md | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/subjects/prime_checker/README.md b/subjects/prime_checker/README.md index 0b115ed86..753e874c1 100644 --- a/subjects/prime_checker/README.md +++ b/subjects/prime_checker/README.md @@ -28,32 +28,8 @@ Here is a program to test your function: use prime_checker::*; fn main() { - println!( - "Is {} prime? {}", - 2, - match prime_checker(2) { - Some(res) => { - match res { - Ok(_) => "Yes, it is!", - Err(_) => "No, it is not!", - } - } - None => "Less than 2", - } - ); - println!( - "Is {} prime? {}", - 14, - match prime_checker(14) { - Some(res) => { - match res { - Ok(_) => "Yes, it is!", - Err(_) => "No, it is not!", - } - } - None => "Less than 2", - } - ); + println!("Is {} prime? {:?}", 2, prime_checker(2)); + println!("Is {} prime? {:?}", 14, prime_checker(14)); } ``` @@ -61,7 +37,7 @@ And its output: ```console $ cargo run -Is 2 prime? Yes, it is! -Is 14 prime? No, it is not! +Is 2 prime? Some(Ok(2)) +Is 14 prime? Some(Err(Even)) $ ```