From 2b85817af8bc4bdfbb155f15367c3ebee09eb743 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 27 Oct 2011 16:27:47 -0700 Subject: [PATCH] Convert various functions in std to take lambda blocks --- src/lib/fun_treemap.rs | 2 +- src/lib/treemap.rs | 2 +- src/lib/vec.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/fun_treemap.rs b/src/lib/fun_treemap.rs index 4e0aea3f3192..1126a13d4493 100644 --- a/src/lib/fun_treemap.rs +++ b/src/lib/fun_treemap.rs @@ -84,7 +84,7 @@ fn find(m: treemap, k: K) -> option { Visit all pairs in the map in order. */ -fn traverse(m: treemap, f: fn(K, V)) { +fn traverse(m: treemap, f: block(K, V)) { alt *m { empty. { } node(@k, @v, _, _) { diff --git a/src/lib/treemap.rs b/src/lib/treemap.rs index 68d732449c65..84fff4992f01 100644 --- a/src/lib/treemap.rs +++ b/src/lib/treemap.rs @@ -83,7 +83,7 @@ fn find(m: treemap, k: K) -> option { Visit all pairs in the map in order. */ -fn traverse(m: treemap, f: fn@(K, V)) { +fn traverse(m: treemap, f: block(K, V)) { alt *m { empty. { } node(k, v, _, _) { diff --git a/src/lib/vec.rs b/src/lib/vec.rs index c4d68590b4d8..3763a13a37a1 100644 --- a/src/lib/vec.rs +++ b/src/lib/vec.rs @@ -48,7 +48,7 @@ fn reserve(&v: [mutable? T], n: uint) { A function used to initialize the elements of a vector. */ -type init_op = fn@(uint) -> T; +type init_op = block(uint) -> T; /* Function: init_fn @@ -327,7 +327,7 @@ fn grow_mut(&v: [mutable T], n: uint, initval: T) { n - The number of elements to add init_fn - A function to call to retreive each appended element's value */ -fn grow_fn(&v: [T], n: uint, init_fn: fn(uint) -> T) { +fn grow_fn(&v: [T], n: uint, init_fn: block(uint) -> T) { reserve(v, next_power_of_two(len(v) + n)); let i: uint = 0u; while i < n { v += [init_fn(i)]; i += 1u; } @@ -513,7 +513,7 @@ fn position(x: T, v: [T]) -> option::t { Find the first index for which the value matches some predicate */ -fn position_pred(f: fn(T) -> bool, v: [T]) -> option::t { +fn position_pred(f: block(T) -> bool, v: [T]) -> option::t { let i: uint = 0u; while i < len(v) { if f(v[i]) { ret some::(i); } i += 1u; } ret none;