mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-12 09:57:43 +00:00
Pass parametric types by-alias in various stdlib spots.
This commit is contained in:
parent
085790a73a
commit
d5fd81174e
@ -32,7 +32,7 @@ fn init_elt[T](&T t, uint n_elts) -> vec[T] {
|
|||||||
/**
|
/**
|
||||||
* FIXME (issue #81): should be:
|
* 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, _);
|
* let init_op[T] inner = bind elt_op[T](t, _);
|
||||||
* ret init_fn[T](inner, n_elts);
|
* 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
|
// Ought to take mutable &vec[T] v and just mutate it instead of copy
|
||||||
// and return. Blocking on issue #89 for this.
|
// 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;
|
let int i = n;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -9,8 +9,8 @@ import std.util;
|
|||||||
import std._vec;
|
import std._vec;
|
||||||
|
|
||||||
|
|
||||||
type hashfn[K] = fn(K) -> uint;
|
type hashfn[K] = fn(&K) -> uint;
|
||||||
type eqfn[K] = fn(K) -> bool;
|
type eqfn[K] = fn(&K) -> bool;
|
||||||
|
|
||||||
type hashmap[K, V] = obj {
|
type hashmap[K, V] = obj {
|
||||||
fn insert(&K key, &V val);
|
fn insert(&K key, &V val);
|
||||||
|
@ -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;
|
ret x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user