about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-10-18 16:02:59 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-10-18 16:02:59 -0700
commit68321b0de87cd40664f490a53a225e4058dd1739 (patch)
tree9eecadef88ec992bb57dd1225c78b0d488f22f05 /src/lib
parent67d442734542ae636b5f2515a9e36909ecd0d8a3 (diff)
Make list.find return an option of different type than the list element.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/list.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/list.rs b/src/lib/list.rs
index 60c23a9ef80..7b8613151e7 100644
--- a/src/lib/list.rs
+++ b/src/lib/list.rs
@@ -26,23 +26,23 @@ fn foldl[T,U](&list[T] ls, U u, fn(&T t, U u) -> U f) -> U {
   }
 }
 
-fn find[T](&list[T] ls,
-             (fn(&T) -> option[T]) f) -> option[T] {
+fn find[T,U](&list[T] ls,
+             (fn(&T) -> option[U]) f) -> option[U] {
   alt(ls) {
     case (cons[T](?hd, ?tl)) {
         alt (f(hd)) {
-            case (none[T]) {
+            case (none[U]) {
                 // FIXME: should use 'be' here, not 'ret'. But parametric tail
                 // calls currently don't work.
-                ret find[T](*tl, f);
+                ret find[T,U](*tl, f);
             }
-            case (some[T](?res)) {
-                ret some[T](res);
+            case (some[U](?res)) {
+                ret some[U](res);
             }
         }
     }
     case (nil[T]) {
-        ret none[T];
+        ret none[U];
     }
   }
 }