From d5fd81174ebbe9f588e9ee9edbb33c2830df948e Mon Sep 17 00:00:00 2001 From: Roy Frostig Date: Tue, 3 Aug 2010 18:06:31 -0700 Subject: [PATCH] Pass parametric types by-alias in various stdlib spots. --- src/lib/_vec.rs | 4 ++-- src/lib/map.rs | 4 ++-- src/lib/util.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/_vec.rs b/src/lib/_vec.rs index 0008295f35f..bec3d99e190 100644 --- a/src/lib/_vec.rs +++ b/src/lib/_vec.rs @@ -32,7 +32,7 @@ fn init_elt[T](&T t, uint n_elts) -> vec[T] { /** * FIXME (issue #81): should be: * - * fn elt_op[T](T x, uint i) -> T { ret x; } + * fn elt_op[T](&T x, uint i) -> T { ret x; } * let init_op[T] inner = bind elt_op[T](t, _); * ret init_fn[T](inner, n_elts); */ @@ -70,7 +70,7 @@ fn slice[T](vec[T] v, int start, int end) -> vec[T] { // Ought to take mutable &vec[T] v and just mutate it instead of copy // and return. Blocking on issue #89 for this. -fn grow[T](mutable vec[T] v, int n, T initval) -> vec[T] { +fn grow[T](mutable vec[T] v, int n, &T initval) -> vec[T] { let int i = n; while (i > 0) { i -= 1; diff --git a/src/lib/map.rs b/src/lib/map.rs index a544aea8871..5c66b7a36af 100644 --- a/src/lib/map.rs +++ b/src/lib/map.rs @@ -9,8 +9,8 @@ import std.util; import std._vec; -type hashfn[K] = fn(K) -> uint; -type eqfn[K] = fn(K) -> bool; +type hashfn[K] = fn(&K) -> uint; +type eqfn[K] = fn(&K) -> bool; type hashmap[K, V] = obj { fn insert(&K key, &V val); diff --git a/src/lib/util.rs b/src/lib/util.rs index 5d0f4b49f8c..1688c263801 100644 --- a/src/lib/util.rs +++ b/src/lib/util.rs @@ -13,7 +13,7 @@ fn option_map[T, U](&operator[T, U] f, &option[T] opt) -> option[U] { } } -fn id[T](T x) -> T { +fn id[T](&T x) -> T { ret x; }