@@ -57,7 +57,6 @@ pub fn unless[T](condition : Bool, value : () -> T) -> Option[T] {
5757 when (condition .not (), value )
5858}
5959
60-
6160/// Creates an empty `Option` of type `T`.
6261pub fn empty [T ]() -> Option [T ] {
6362 None
@@ -103,8 +102,8 @@ pub fn bind[T, U](self : Option[T], f : (T) -> Option[U]) -> Option[U] {
103102test "bind" {
104103 let a = Option ::Some (5 )
105104 let b : Option [Int ] = None
106- @assertion .assert_eq (a .bind (fn (x ){ Some (x * 2 ) }), Some (10 ))?
107- @assertion .assert_eq (b .bind (fn (x ){ Some (x * 2 ) }), None )?
105+ @assertion .assert_eq (a .bind (fn (x ) { Some (x * 2 ) }), Some (10 ))?
106+ @assertion .assert_eq (b .bind (fn (x ) { Some (x * 2 ) }), None )?
108107}
109108
110109/// Flattens an `Option` of `Option` into a single `Option`.
@@ -124,10 +123,10 @@ pub fn flatten[T](self : Option[Option[T]]) -> Option[T] {
124123}
125124
126125test "flatten" {
127- let a : Option [Option [Int ]] = Some (Some (42 ));
128- @assertion .assert_eq (flatten (a ),Some (42 ))?
126+ let a : Option [Option [Int ]] = Some (Some (42 ))
127+ @assertion .assert_eq (flatten (a ), Some (42 ))?
129128 let b : Option [Option [Int ]] = Some (None )
130- @assertion .assert_eq (flatten (b ),None )?
129+ @assertion .assert_eq (flatten (b ), None )?
131130}
132131
133132/// Checks if the option is empty.
@@ -140,7 +139,7 @@ pub fn is_empty[T](self : Option[T]) -> Bool {
140139
141140test "is_empty" {
142141 let x = Option ::Some (3 )
143- let y : Option [Int ] = None
142+ let y : Option [Int ] = None
144143 @assertion .assert_false (x .is_empty ())?
145144 @assertion .assert_true (y .is_empty ())?
146145}
@@ -166,8 +165,8 @@ pub fn filter[T](self : Option[T], f : (T) -> Bool) -> Option[T] {
166165
167166test "filter" {
168167 let x = Option ::Some (3 )
169- @assertion .assert_eq (x .filter (fn (x ){ x > 5 }),None )?
170- @assertion .assert_eq (x .filter (fn (x ){ x < 5 }),Some (3 ))?
168+ @assertion .assert_eq (x .filter (fn (x ) { x > 5 }), None )?
169+ @assertion .assert_eq (x .filter (fn (x ) { x < 5 }), Some (3 ))?
171170}
172171
173172/// Return the contained `Some` value or the provided default.
@@ -196,6 +195,6 @@ pub fn or_else[T](self : Option[T], default : () -> T) -> T {
196195
197196test "or else" {
198197 let x = Option ::Some (3 )
199- @assertion .assert_eq (x .or_else (fn () { 5 }), 3 )?
200- @assertion .assert_eq ((None : Option [Int ]).or_else (fn () { 5 }), 5 )?
201- }
198+ @assertion .assert_eq (x .or_else (fn () { 5 }), 3 )?
199+ @assertion .assert_eq ((None : Option [Int ]).or_else (fn () { 5 }), 5 )?
200+ }
0 commit comments