diff options
| author | Patrick Walton <[email protected]> | 2010-11-05 10:41:23 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2010-11-05 10:41:23 -0700 |
| commit | 2fcf81cc4b132bf7d862f5144d282391b38d0c15 (patch) | |
| tree | d6e2c25528a83959111707cd7e29b4b30b93cf6a /src/lib/util.rs | |
| parent | rustboot: Describe the cycle when reporting a cyclic import error (diff) | |
| download | rust-2fcf81cc4b132bf7d862f5144d282391b38d0c15.tar.xz rust-2fcf81cc4b132bf7d862f5144d282391b38d0c15.zip | |
Revert "Move the option type to its own module"
Diffstat (limited to 'src/lib/util.rs')
| -rw-r--r-- | src/lib/util.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/util.rs b/src/lib/util.rs index 72844d5f..f6e1327b 100644 --- a/src/lib/util.rs +++ b/src/lib/util.rs @@ -1,3 +1,21 @@ +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; } |