46
46
//! // The division was valid
47
47
//! Some(x) => println!("Result: {}", x),
48
48
//! // The division was invalid
49
- //! None => println!("Cannot divide by 0")
49
+ //! None => println!("Cannot divide by 0"),
50
50
//! }
51
51
//! ```
52
52
//!
75
75
//! fn check_optional(optional: &Option<Box<i32>>) {
76
76
//! match *optional {
77
77
//! Some(ref p) => println!("have value {}", p),
78
- //! None => println!("have no value")
78
+ //! None => println!("have no value"),
79
79
//! }
80
80
//! }
81
81
//! ```
95
95
//! // Take a reference to the contained string
96
96
//! match msg {
97
97
//! Some(ref m) => println!("{}", *m),
98
- //! None => ()
98
+ //! None => (),
99
99
//! }
100
100
//!
101
101
//! // Remove the contained string, destroying the Option
102
102
//! let unwrapped_msg = match msg {
103
103
//! Some(m) => m,
104
- //! None => "default message"
104
+ //! None => "default message",
105
105
//! };
106
106
//! ```
107
107
//!
137
137
//!
138
138
//! match name_of_biggest_animal {
139
139
//! Some(name) => println!("the biggest animal is {}", name),
140
- //! None => println!("there are no animals :(")
140
+ //! None => println!("there are no animals :("),
141
141
//! }
142
142
//! ```
143
143
@@ -198,7 +198,7 @@ impl<T> Option<T> {
198
198
pub fn is_some ( & self ) -> bool {
199
199
match * self {
200
200
Some ( _) => true ,
201
- None => false
201
+ None => false ,
202
202
}
203
203
}
204
204
@@ -244,7 +244,7 @@ impl<T> Option<T> {
244
244
pub fn as_ref < ' r > ( & ' r self ) -> Option < & ' r T > {
245
245
match * self {
246
246
Some ( ref x) => Some ( x) ,
247
- None => None
247
+ None => None ,
248
248
}
249
249
}
250
250
@@ -265,7 +265,7 @@ impl<T> Option<T> {
265
265
pub fn as_mut < ' r > ( & ' r mut self ) -> Option < & ' r mut T > {
266
266
match * self {
267
267
Some ( ref mut x) => Some ( x) ,
268
- None => None
268
+ None => None ,
269
269
}
270
270
}
271
271
@@ -376,7 +376,7 @@ impl<T> Option<T> {
376
376
pub fn unwrap_or ( self , def : T ) -> T {
377
377
match self {
378
378
Some ( x) => x,
379
- None => def
379
+ None => def,
380
380
}
381
381
}
382
382
@@ -394,7 +394,7 @@ impl<T> Option<T> {
394
394
pub fn unwrap_or_else < F : FnOnce ( ) -> T > ( self , f : F ) -> T {
395
395
match self {
396
396
Some ( x) => x,
397
- None => f ( )
397
+ None => f ( ) ,
398
398
}
399
399
}
400
400
@@ -420,7 +420,7 @@ impl<T> Option<T> {
420
420
pub fn map < U , F : FnOnce ( T ) -> U > ( self , f : F ) -> Option < U > {
421
421
match self {
422
422
Some ( x) => Some ( f ( x) ) ,
423
- None => None
423
+ None => None ,
424
424
}
425
425
}
426
426
@@ -464,7 +464,7 @@ impl<T> Option<T> {
464
464
pub fn map_or_else < U , D : FnOnce ( ) -> U , F : FnOnce ( T ) -> U > ( self , default : D , f : F ) -> U {
465
465
match self {
466
466
Some ( t) => f ( t) ,
467
- None => default ( )
467
+ None => default ( ) ,
468
468
}
469
469
}
470
470
@@ -637,7 +637,7 @@ impl<T> Option<T> {
637
637
pub fn or ( self , optb : Option < T > ) -> Option < T > {
638
638
match self {
639
639
Some ( _) => self ,
640
- None => optb
640
+ None => optb,
641
641
}
642
642
}
643
643
@@ -659,7 +659,7 @@ impl<T> Option<T> {
659
659
pub fn or_else < F : FnOnce ( ) -> Option < T > > ( self , f : F ) -> Option < T > {
660
660
match self {
661
661
Some ( _) => self ,
662
- None => f ( )
662
+ None => f ( ) ,
663
663
}
664
664
}
665
665
@@ -736,7 +736,7 @@ impl<T: Default> Option<T> {
736
736
pub fn unwrap_or_default ( self ) -> T {
737
737
match self {
738
738
Some ( x) => x,
739
- None => Default :: default ( )
739
+ None => Default :: default ( ) ,
740
740
}
741
741
}
742
742
}
0 commit comments