There was no case analysis there! Instead, the case analysis was put inside the
`unwrap` method for you. You could define it yourself if you want:
+<div id="code-option-def-unwrap">
```rust
enum Option<T> {
None,
}
}
```
+</div>
The `unwrap` method *abstracts away the case analysis*. This is precisely the thing
that makes `unwrap` ergonomic to use. Unfortunately, that `panic!` means that
Rust has parametric polymorphism, so it is very easy to define a combinator
that abstracts this pattern:
+<div id="code-option-map">
```rust
fn map<F, T, A>(option: Option<T>, f: F) -> Option<A> where F: FnOnce(T) -> A {
match option {
}
}
```
+</div>
Indeed, `map` is [defined as a method][2] on `Option<T>` in the standard library.
The `Result` type is also
[defined in the standard library][6]:
+<div id="code-result-def-1">
```rust
enum Result<T, E> {
Ok(T),
Err(E),
}
```
+</div>
The `Result` type is a richer version of `Option`. Instead of expressing the
possibility of *absence* like `Option` does, `Result` expresses the possibility
(from `env::args()`) means the user didn't invoke the program correctly. We
could just use a `String` to describe the error. Let's try:
+<div id="code-error-double-string">
```rust
use std::env;
}
}
```
+</div>
There are a couple new things in this example. The first is the use of the
[`Option::ok_or`](../std/option/enum.Option.html#method.ok_or)
Here is a simplified definition of a `try!` macro:
+<div id="code-try-def-simple">
```rust
macro_rules! try {
($e:expr) => (match $e {
});
}
```
+</div>
(The [real definition](../std/macro.try!.html) is a bit more
sophisticated. We will address that later.)
[defined in the standard
library](../std/convert/trait.From.html):
+<div id="code-from-def">
```rust
trait From<T> {
fn from(T) -> Self;
}
```
+</div>
Deliciously simple, yes? `From` is very useful because it gives us a generic
way to talk about conversion *from* a particular type `T` to some other type
This is not it's real definition. It's real definition is
[in the standard library](../std/macro.try!.html):
+<div id="code-try-def">
```rust
macro_rules! try {
($e:expr) => (match $e {
});
}
```
+</div>
There's one tiny but powerful change: the error value is passed through
`From::from`. This makes the `try!` macro a lot more powerful because it gives