From 0fc14dfe5b77eadb8743eff09c1a5c753fbd24f6 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 17 Oct 2016 16:30:28 -0400 Subject: [PATCH] Add a summary --- src/ch09-03-to-panic-or-not-to-panic.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ch09-03-to-panic-or-not-to-panic.md b/src/ch09-03-to-panic-or-not-to-panic.md index a3af18bb3..300eb1f96 100644 --- a/src/ch09-03-to-panic-or-not-to-panic.md +++ b/src/ch09-03-to-panic-or-not-to-panic.md @@ -149,5 +149,16 @@ would not need to do any additional checks in its body. ## Summary -Now that we've reduced duplication in our validation code, let's look at a -feature of Rust that helps reduce duplication in lots of code: generics! +Rust's error handling features are designed to help you write more robust code. +The `panic!` macro signals that your program is in a state it can't handle, and +lets you tell the process to stop instead of trying to proceed with invalid or +incorrect values. The `Result` enum uses Rust's type system as a sign that +operations you call might fail in a way that your code could recover from. You +can use `Result` to tell code that calls yours that it needs to handle +potential success or failure as well. Using `panic!` and `Result` in the +appropriate situations will help your code be more reliable in the face of +inevitable problems. + +Now that we've seen useful ways that the standard library uses generics with +the `Option` and `Result` enums, let's talk about how generics work and how you +can make use of them in your code.