From 2fcf81cc4b132bf7d862f5144d282391b38d0c15 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 5 Nov 2010 10:41:23 -0700 Subject: Revert "Move the option type to its own module" --- src/lib/util.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/lib/util.rs') 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; } -- cgit v1.2.3