mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-02-24 21:32:15 +08:00
18 lines
297 B
Rust
Executable File
18 lines
297 B
Rust
Executable File
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
|