about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2011-12-16 06:27:50 -0800
committerNiko Matsakis <niko@alum.mit.edu>2011-12-16 07:17:23 -0800
commit2833ca478c19d2f8f150570a6d60b93488debdcc (patch)
tree041865de99eb77a1d4504ee29c38691a7f872f34 /src/libcore
parent0a3626161d5ebb1d2c6839773b0e533d3ec4589c (diff)
downloadrust-2833ca478c19d2f8f150570a6d60b93488debdcc.tar.gz
rust-2833ca478c19d2f8f150570a6d60b93488debdcc.zip
reorder args to the various vec, option fns so blk comes last
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/option.rs6
-rw-r--r--src/libcore/vec.rs22
2 files changed, 14 insertions, 14 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 403cb47f47e..b46798894b7 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -36,7 +36,7 @@ fn get<copy T>(opt: t<T>) -> T {
 
 /*
 */
-fn map<T, U>(f: block(T) -> U, opt: t<T>) -> t<U> {
+fn map<T, U>(opt: t<T>, f: block(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>(def: U, f: block(T) -> U, opt: t<T>) -> U {
+fn maybe<T, U>(def: U, opt: t<T>, f: block(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>(f: block(T), opt: t<T>) {
+fn may<T>(opt: t<T>, f: block(T)) {
     alt opt { none. {/* nothing */ } some(t) { f(t); } }
 }
 
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs
index d8f89b3b27b..9fe10692cc6 100644
--- a/src/libcore/vec.rs
+++ b/src/libcore/vec.rs
@@ -384,7 +384,7 @@ Function: map
 
 Apply a function to each element of a vector and return the results
 */
-fn map<T, U>(f: block(T) -> U, v: [T]) -> [U] {
+fn map<T, U>(v: [T], f: block(T) -> U) -> [U] {
     let result = [];
     reserve(result, len(v));
     for elem: T in v { result += [f(elem)]; }
@@ -396,7 +396,7 @@ Function: map_mut
 
 Apply a function to each element of a mutable vector and return the results
 */
-fn map_mut<copy T, U>(f: block(T) -> U, v: [const T]) -> [U] {
+fn map_mut<copy T, U>(v: [const T], f: block(T) -> U) -> [U] {
     let result = [];
     reserve(result, len(v));
     for elem: T in v {
@@ -411,7 +411,7 @@ Function: map2
 
 Apply a function to each pair of elements and return the results
 */
-fn map2<copy T, copy U, V>(f: block(T, U) -> V, v0: [T], v1: [U]) -> [V] {
+fn map2<copy T, copy U, V>(v0: [T], v1: [U], f: block(T, U) -> V) -> [V] {
     let v0_len = len(v0);
     if v0_len != len(v1) { fail; }
     let u: [V] = [];
@@ -428,7 +428,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<copy T, copy U>(f: block(T) -> option::t<U>, v: [const T])
+fn filter_map<copy T, copy U>(v: [const T], f: block(T) -> option::t<U>)
     -> [U] {
     let result = [];
     for elem: T in v {
@@ -449,7 +449,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<copy T>(f: block(T) -> bool, v: [T]) -> [T] {
+fn filter<copy T>(v: [T], f: block(T) -> bool) -> [T] {
     let result = [];
     for elem: T in v {
         if f(elem) { result += [elem]; }
@@ -474,7 +474,7 @@ Function: foldl
 
 Reduce a vector from left to right
 */
-fn foldl<copy T, U>(p: block(T, U) -> T, z: T, v: [const U]) -> T {
+fn foldl<copy T, U>(z: T, v: [const U], p: block(T, U) -> T) -> T {
     let accum = z;
     iter(v) { |elt|
         accum = p(accum, elt);
@@ -487,7 +487,7 @@ Function: foldr
 
 Reduce a vector from right to left
 */
-fn foldr<T, copy U>(p: block(T, U) -> U, z: U, v: [const T]) -> U {
+fn foldr<T, copy U>(v: [const T], z: U, p: block(T, U) -> U) -> U {
     let accum = z;
     riter(v) { |elt|
         accum = p(elt, accum);
@@ -502,7 +502,7 @@ Return true if a predicate matches any elements
 
 If the vector contains no elements then false is returned.
 */
-fn any<T>(f: block(T) -> bool, v: [T]) -> bool {
+fn any<T>(v: [T], f: block(T) -> bool) -> bool {
     for elem: T in v { if f(elem) { ret true; } }
     ret false;
 }
@@ -514,7 +514,7 @@ Return true if a predicate matches all elements
 
 If the vector contains no elements then true is returned.
 */
-fn all<T>(f: block(T) -> bool, v: [T]) -> bool {
+fn all<T>(v: [T], f: block(T) -> bool) -> bool {
     for elem: T in v { if !f(elem) { ret false; } }
     ret true;
 }
@@ -549,7 +549,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<copy T>(f: block(T) -> bool, v: [T]) -> option::t<T> {
+fn find<copy T>(v: [T], f: block(T) -> bool) -> option::t<T> {
     for elt: T in v { if f(elt) { ret some(elt); } }
     ret none;
 }
@@ -575,7 +575,7 @@ Function: position_pred
 
 Find the first index for which the value matches some predicate
 */
-fn position_pred<T>(f: block(T) -> bool, v: [T]) -> option::t<uint> {
+fn position_pred<T>(v: [T], f: block(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;