diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-01-23 14:59:00 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-01-23 19:06:33 -0800 |
| commit | 5e13d19cc07a1e8fbf478d21cabbd7b9f80e3b54 (patch) | |
| tree | c1fc2dd89c651efa1daa4e7d63c5b82b2a5f4bd2 /src/libcore | |
| parent | 04351a84ca342f4580e40b9c195b5403b864090b (diff) | |
| download | rust-5e13d19cc07a1e8fbf478d21cabbd7b9f80e3b54.tar.gz rust-5e13d19cc07a1e8fbf478d21cabbd7b9f80e3b54.zip | |
s/block()/fn()/g
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/bool.rs | 2 | ||||
| -rw-r--r-- | src/libcore/either.rs | 2 | ||||
| -rw-r--r-- | src/libcore/int.rs | 2 | ||||
| -rw-r--r-- | src/libcore/option.rs | 6 | ||||
| -rw-r--r-- | src/libcore/result.rs | 2 | ||||
| -rw-r--r-- | src/libcore/str.rs | 8 | ||||
| -rw-r--r-- | src/libcore/u32.rs | 2 | ||||
| -rw-r--r-- | src/libcore/u64.rs | 2 | ||||
| -rw-r--r-- | src/libcore/u8.rs | 2 | ||||
| -rw-r--r-- | src/libcore/uint.rs | 4 | ||||
| -rw-r--r-- | src/libcore/vec.rs | 40 |
11 files changed, 36 insertions, 36 deletions
diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 3b358011422..d027e3825e1 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -75,7 +75,7 @@ pure fn to_str(v: t) -> str { if v { "true" } else { "false" } } brief = "Iterates over all truth values by passing them to `blk` \ in an unspecified order" )] -fn all_values(blk: block(v: t)) { +fn all_values(blk: fn(v: t)) { blk(true); blk(false); } diff --git a/src/libcore/either.rs b/src/libcore/either.rs index d605b575901..e3dadaa7e38 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -29,7 +29,7 @@ If `value` is left(T) then `f_left` is applied to its contents, if the result is returned. */ fn either<T, U, - V>(f_left: block(T) -> V, f_right: block(U) -> V, value: t<T, U>) -> + V>(f_left: fn(T) -> V, f_right: fn(U) -> V, value: t<T, U>) -> V { alt value { left(l) { f_left(l) } right(r) { f_right(r) } } } diff --git a/src/libcore/int.rs b/src/libcore/int.rs index ca48e83011c..47a699b834e 100644 --- a/src/libcore/int.rs +++ b/src/libcore/int.rs @@ -84,7 +84,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: int, hi: int, it: block(int)) { +fn range(lo: int, hi: int, it: fn(int)) { let i = lo; while i < hi { it(i); i += 1; } } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 8cba1c84dc0..c86127b4664 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -36,7 +36,7 @@ pure fn get<T: copy>(opt: t<T>) -> T { /* */ -fn map<T, U: copy>(opt: t<T>, f: block(T) -> U) -> t<U> { +fn map<T, U: copy>(opt: t<T>, f: fn(T) -> U) -> t<U> { alt opt { some(x) { some(f(x)) } none { none } } } @@ -70,7 +70,7 @@ Function: maybe Applies a function to the contained value or returns a default */ -fn maybe<T, U: copy>(def: U, opt: t<T>, f: block(T) -> U) -> U { +fn maybe<T, U: copy>(def: U, opt: t<T>, f: fn(T) -> U) -> U { alt opt { none { def } some(t) { f(t) } } } @@ -80,7 +80,7 @@ Function: may Performs an operation on the contained value or does nothing */ -fn may<T>(opt: t<T>, f: block(T)) { +fn may<T>(opt: t<T>, f: fn(T)) { alt opt { none {/* nothing */ } some(t) { f(t); } } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 0b229110ec3..52c3ff95d23 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -110,7 +110,7 @@ Example: > }) */ -fn chain<T, U: copy, V: copy>(res: t<T, V>, op: block(T) -> t<U, V>) +fn chain<T, U: copy, V: copy>(res: t<T, V>, op: fn(T) -> t<U, V>) -> t<U, V> { alt res { ok(t) { op(t) } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index b24c2158d41..1cccaf0f641 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -347,7 +347,7 @@ Function: iter_chars Iterate over the characters in a string */ -fn iter_chars(s: str, it: block(char)) { +fn iter_chars(s: str, it: fn(char)) { let pos = 0u, len = byte_len(s); while (pos < len) { let {ch, next} = char_range_at(s, pos); @@ -371,7 +371,7 @@ Returns: `true` If execution proceeded correctly, `false` if it was interrupted, that is if `it` returned `false` at any point. */ -fn loop_chars(s: str, it: block(char) -> bool) -> bool{ +fn loop_chars(s: str, it: fn(char) -> bool) -> bool{ ret loop_chars_sub(s, 0u, byte_len(s), it); } @@ -398,7 +398,7 @@ Safety note: represent valid positions inside `s` */ fn loop_chars_sub(s: str, byte_offset: uint, byte_len: uint, - it: block(char) -> bool) -> bool { + it: fn(char) -> bool) -> bool { let i = byte_offset; let result = true; while i < byte_len { @@ -1061,7 +1061,7 @@ Example: > let s = str::as_buf("PATH", { |path_buf| libc::getenv(path_buf) }); */ -fn as_buf<T>(s: str, f: block(sbuf) -> T) -> T unsafe { +fn as_buf<T>(s: str, f: fn(sbuf) -> T) -> T unsafe { let buf = buf(s); f(buf) } diff --git a/src/libcore/u32.rs b/src/libcore/u32.rs index 569d59b981a..45e54bb5069 100644 --- a/src/libcore/u32.rs +++ b/src/libcore/u32.rs @@ -54,7 +54,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: u32, hi: u32, it: block(u32)) { +fn range(lo: u32, hi: u32, it: fn(u32)) { let i = lo; while i < hi { it(i); i += 1u32; } } diff --git a/src/libcore/u64.rs b/src/libcore/u64.rs index bce99f02b87..472702c8eac 100644 --- a/src/libcore/u64.rs +++ b/src/libcore/u64.rs @@ -54,7 +54,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: u64, hi: u64, it: block(u64)) { +fn range(lo: u64, hi: u64, it: fn(u64)) { let i = lo; while i < hi { it(i); i += 1u64; } } diff --git a/src/libcore/u8.rs b/src/libcore/u8.rs index eadfcadda4a..b025751020b 100644 --- a/src/libcore/u8.rs +++ b/src/libcore/u8.rs @@ -54,7 +54,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: u8, hi: u8, it: block(u8)) { +fn range(lo: u8, hi: u8, it: fn(u8)) { let i = lo; while i < hi { it(i); i += 1u8; } } diff --git a/src/libcore/uint.rs b/src/libcore/uint.rs index 598c6baffe4..8d032610e17 100644 --- a/src/libcore/uint.rs +++ b/src/libcore/uint.rs @@ -115,7 +115,7 @@ Function: range Iterate over the range [`lo`..`hi`) */ -fn range(lo: uint, hi: uint, it: block(uint)) { +fn range(lo: uint, hi: uint, it: fn(uint)) { let i = lo; while i < hi { it(i); i += 1u; } } @@ -136,7 +136,7 @@ Returns: `true` If execution proceeded correctly, `false` if it was interrupted, that is if `it` returned `false` at any point. */ -fn loop(lo: uint, hi: uint, it: block(uint) -> bool) -> bool { +fn loop(lo: uint, hi: uint, it: fn(uint) -> bool) -> bool { let i = lo; while i < hi { if (!it(i)) { ret false; } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index f677af1efc7..0a1a4012422 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -26,7 +26,7 @@ Type: init_op A function used to initialize the elements of a vector. */ -type init_op<T> = block(uint) -> T; +type init_op<T> = fn(uint) -> T; /* @@ -402,7 +402,7 @@ Function: map Apply a function to each element of a vector and return the results */ -fn map<T, U>(v: [T], f: block(T) -> U) -> [U] { +fn map<T, U>(v: [T], f: fn(T) -> U) -> [U] { let result = []; reserve(result, len(v)); for elem: T in v { result += [f(elem)]; } @@ -414,7 +414,7 @@ Function: map_mut Apply a function to each element of a mutable vector and return the results */ -fn map_mut<T: copy, U>(v: [const T], f: block(T) -> U) -> [U] { +fn map_mut<T: copy, U>(v: [const T], f: fn(T) -> U) -> [U] { let result = []; reserve(result, len(v)); for elem: T in v { @@ -429,7 +429,7 @@ Function: map2 Apply a function to each pair of elements and return the results */ -fn map2<T: copy, U: copy, V>(v0: [T], v1: [U], f: block(T, U) -> V) -> [V] { +fn map2<T: copy, U: copy, V>(v0: [T], v1: [U], f: fn(T, U) -> V) -> [V] { let v0_len = len(v0); if v0_len != len(v1) { fail; } let u: [V] = []; @@ -446,7 +446,7 @@ Apply a function to each element of a vector and return the results If function `f` returns `none` then that element is excluded from the resulting vector. */ -fn filter_map<T: copy, U: copy>(v: [const T], f: block(T) -> option::t<U>) +fn filter_map<T: copy, U: copy>(v: [const T], f: fn(T) -> option::t<U>) -> [U] { let result = []; for elem: T in v { @@ -467,7 +467,7 @@ holds. Apply function `f` to each element of `v` and return a vector containing only those elements for which `f` returned true. */ -fn filter<T: copy>(v: [T], f: block(T) -> bool) -> [T] { +fn filter<T: copy>(v: [T], f: fn(T) -> bool) -> [T] { let result = []; for elem: T in v { if f(elem) { result += [elem]; } @@ -492,7 +492,7 @@ Function: foldl Reduce a vector from left to right */ -fn foldl<T: copy, U>(z: T, v: [const U], p: block(T, U) -> T) -> T { +fn foldl<T: copy, U>(z: T, v: [const U], p: fn(T, U) -> T) -> T { let accum = z; iter(v) { |elt| accum = p(accum, elt); @@ -505,7 +505,7 @@ Function: foldr Reduce a vector from right to left */ -fn foldr<T, U: copy>(v: [const T], z: U, p: block(T, U) -> U) -> U { +fn foldr<T, U: copy>(v: [const T], z: U, p: fn(T, U) -> U) -> U { let accum = z; riter(v) { |elt| accum = p(elt, accum); @@ -520,7 +520,7 @@ Return true if a predicate matches any elements If the vector contains no elements then false is returned. */ -fn any<T>(v: [T], f: block(T) -> bool) -> bool { +fn any<T>(v: [T], f: fn(T) -> bool) -> bool { for elem: T in v { if f(elem) { ret true; } } ret false; } @@ -532,7 +532,7 @@ Return true if a predicate matches any elements in both vectors. If the vectors contains no elements then false is returned. */ -fn any2<T, U>(v0: [T], v1: [U], f: block(T, U) -> bool) -> bool { +fn any2<T, U>(v0: [T], v1: [U], f: fn(T, U) -> bool) -> bool { let v0_len = len(v0); let v1_len = len(v1); let i = 0u; @@ -550,7 +550,7 @@ Return true if a predicate matches all elements If the vector contains no elements then true is returned. */ -fn all<T>(v: [T], f: block(T) -> bool) -> bool { +fn all<T>(v: [T], f: fn(T) -> bool) -> bool { for elem: T in v { if !f(elem) { ret false; } } ret true; } @@ -562,7 +562,7 @@ Return true if a predicate matches all elements in both vectors. If the vectors are not the same size then false is returned. */ -fn all2<T, U>(v0: [T], v1: [U], f: block(T, U) -> bool) -> bool { +fn all2<T, U>(v0: [T], v1: [U], f: fn(T, U) -> bool) -> bool { let v0_len = len(v0); if v0_len != len(v1) { ret false; } let i = 0u; @@ -600,7 +600,7 @@ Apply function `f` to each element of `v`, starting from the first. When function `f` returns true then an option containing the element is returned. If `f` matches no elements then none is returned. */ -fn find<T: copy>(v: [T], f: block(T) -> bool) -> option::t<T> { +fn find<T: copy>(v: [T], f: fn(T) -> bool) -> option::t<T> { for elt: T in v { if f(elt) { ret some(elt); } } ret none; } @@ -626,7 +626,7 @@ Function: position_pred Find the first index for which the value matches some predicate */ -fn position_pred<T>(v: [T], f: block(T) -> bool) -> option::t<uint> { +fn position_pred<T>(v: [T], f: fn(T) -> bool) -> option::t<uint> { let i: uint = 0u; while i < len(v) { if f(v[i]) { ret some::<uint>(i); } i += 1u; } ret none; @@ -747,7 +747,7 @@ Iterates over vector `v` and, for each element, calls function `f` with the element's value. */ -fn iter<T>(v: [const T], f: block(T)) { +fn iter<T>(v: [const T], f: fn(T)) { iteri(v) { |_i, v| f(v) } } @@ -757,7 +757,7 @@ Function: iter2 Iterates over two vectors in parallel */ -fn iter2<U, T>(v: [U], v2: [T], f: block(U, T)) { +fn iter2<U, T>(v: [U], v2: [T], f: fn(U, T)) { let i = 0; for elt in v { f(elt, v2[i]); i += 1; } } @@ -770,7 +770,7 @@ Iterates over a vector's elements and indexes Iterates over vector `v` and, for each element, calls function `f` with the element's value and index. */ -fn iteri<T>(v: [const T], f: block(uint, T)) { +fn iteri<T>(v: [const T], f: fn(uint, T)) { let i = 0u, l = len(v); while i < l { f(i, v[i]); i += 1u; } } @@ -784,7 +784,7 @@ Iterates over vector `v` and, for each element, calls function `f` with the element's value. */ -fn riter<T>(v: [const T], f: block(T)) { +fn riter<T>(v: [const T], f: fn(T)) { riteri(v) { |_i, v| f(v) } } @@ -796,7 +796,7 @@ Iterates over a vector's elements and indexes in reverse Iterates over vector `v` and, for each element, calls function `f` with the element's value and index. */ -fn riteri<T>(v: [const T], f: block(uint, T)) { +fn riteri<T>(v: [const T], f: fn(uint, T)) { let i = len(v); while 0u < i { i -= 1u; @@ -814,7 +814,7 @@ is sorted then the permutations are lexicographically sorted). The total number of permutations produced is `len(v)!`. If `v` contains repeated elements, then some permutations are repeated. */ -fn permute<T: copy>(v: [const T], put: block([T])) { +fn permute<T: copy>(v: [const T], put: fn([T])) { let ln = len(v); if ln == 0u { put([]); |
