Skip to content

Commit e3a066b

Browse files
committed
Swap arg order for option::{may,maybe}
This lets us write the block syntax sugar: option::may(x) { |y| … }
1 parent 44ffd8e commit e3a066b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Function: maybe
7070
7171
Applies a function to the contained value or returns a default
7272
*/
73-
fn maybe<T, U>(def: U, f: block(T) -> U, opt: t<T>) -> U {
73+
fn maybe<T, U>(def: U, opt: t<T>, f: block(T) -> U) -> U {
7474
alt opt { none. { def } some(t) { f(t) } }
7575
}
7676

@@ -80,7 +80,7 @@ Function: may
8080
8181
Performs an operation on the contained value or does nothing
8282
*/
83-
fn may<T>(f: block(T), opt: t<T>) {
83+
fn may<T>(opt: t<T>, f: block(T)) {
8484
alt opt { none. {/* nothing */ } some(t) { f(t); } }
8585
}
8686

0 commit comments

Comments
 (0)