Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused_variables)]
- #[derive(Debug)]
- fn main() {
- let five = Option::Some(5);
- let six = plus_one(&five);
- let none = plus_one(&Option::None);
- println!("five: {:?}", five);
- println!("six: {:?}", six);
- println!("none: {:?}", none);
- }
- enum Option<T> {
- Some(T),
- None,
- }
- fn plus_one(x: &Option<i32>) -> Option<i32> {
- match x {
- Option::None => Option::None,
- Option::Some(i) => Option::Some(i + 1),
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement