Add a summary

This commit is contained in:
Carol (Nichols || Goulding)
2016-10-17 16:30:28 -04:00
parent 211aec84b9
commit 0fc14dfe5b
+13 -2
View File
@@ -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.