Move the option type to its own module
This commit is contained in:
parent
e399926776
commit
adb1754e4d
14 changed files with 115 additions and 93 deletions
|
|
@ -1,21 +1,3 @@
|
|||
tag option[T] {
|
||||
none;
|
||||
some(T);
|
||||
}
|
||||
|
||||
type operator[T, U] = fn(&T) -> U;
|
||||
|
||||
fn option_map[T, U](&operator[T, U] f, &option[T] opt) -> option[U] {
|
||||
alt (opt) {
|
||||
case (some[T](?x)) {
|
||||
ret some[U](f(x));
|
||||
}
|
||||
case (none[T]) {
|
||||
ret none[U];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn id[T](&T x) -> T {
|
||||
ret x;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue