@@ -87,20 +87,26 @@ pure fn unwrap<T>(-opt: option<T>) -> T unsafe {
87
87
ret liberated_value;
88
88
}
89
89
90
- impl extensions<T : copy > for option < T > {
90
+ impl extensions<T > for option < T > {
91
91
#[ doc = "
92
92
Update an optional value by optionally running its content through a
93
93
function that returns an option.
94
94
" ]
95
95
fn chain < U > ( f : fn ( T ) -> option < U > ) -> option < U > { chain ( self , f) }
96
- #[ doc = "Returns the contained value or a default" ]
97
- fn get_default ( def : T ) -> T { get_default ( self , def) }
98
96
#[ doc = "Applies a function to the contained value or returns a default" ]
99
97
fn map_default < U : copy > ( def : U , f : fn ( T ) -> U ) -> U
100
98
{ map_default ( self , def, f) }
101
99
#[ doc = "Performs an operation on the contained value or does nothing" ]
102
100
fn iter ( f : fn ( T ) ) { iter ( self , f) }
101
+ #[ doc = "Returns true if the option equals `none`" ]
102
+ fn is_none ( ) -> bool { is_none ( self ) }
103
+ #[ doc = "Returns true if the option contains some value" ]
104
+ fn is_some ( ) -> bool { is_some ( self ) }
105
+ #[ doc = "Maps a `some` value from one type to another" ]
106
+ fn map < U : copy > ( f : fn ( T ) -> U ) -> option < U > { map ( self , f) }
107
+ }
103
108
109
+ impl extensions < T : copy > for option < T > {
104
110
#[ doc = "
105
111
Gets the value out of an option
106
112
@@ -109,12 +115,7 @@ impl extensions<T:copy> for option<T> {
109
115
Fails if the value equals `none`
110
116
" ]
111
117
fn get ( ) -> T { get ( self ) }
112
- #[ doc = "Returns true if the option equals `none`" ]
113
- fn is_none ( ) -> bool { is_none ( self ) }
114
- #[ doc = "Returns true if the option contains some value" ]
115
- fn is_some ( ) -> bool { is_some ( self ) }
116
- #[ doc = "Maps a `some` value from one type to another" ]
117
- fn map < U : copy > ( f : fn ( T ) -> U ) -> option < U > { map ( self , f) }
118
+ fn get_default ( def : T ) -> T { get_default ( self , def) }
118
119
}
119
120
120
121
#[ test]
0 commit comments