mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
297 B
18 lines
297 B
3 years ago
|
enum Option<T> {
|
||
|
Some(T),
|
||
|
None,
|
||
|
}
|
||
|
|
||
|
use crate::Option::*;
|
||
|
|
||
|
// ANCHOR: here
|
||
|
impl<T> Option<T> {
|
||
|
pub fn unwrap(self) -> T {
|
||
|
match self {
|
||
|
Some(val) => val,
|
||
|
None => panic!("called `Option::unwrap()` on a `None` value"),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
// ANCHOR_END: here
|