diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 77b9a3ce8fb7..ebc768931b53 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -248,10 +248,10 @@ pure fn build_sized_opt>( // Functions that combine iteration and building /// Apply a function to each element of an iterable and return the results -fn map,U,BU: Buildable>(v: IT, f: fn(T) -> U) -> BU { +fn map,U,BU: Buildable>(v: &IT, f: fn(&T) -> U) -> BU { do build_sized_opt(v.size_hint()) |push| { for v.each() |elem| { - push(f(*elem)); + push(f(elem)); } } } @@ -275,17 +275,17 @@ pure fn from_fn>(n_elts: uint, op: InitOp) -> BT { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pure fn from_elem>(n_elts: uint, t: T) -> BT { +pure fn from_elem>(n_elts: uint, +t: T) -> BT { do build_sized(n_elts) |push| { - let mut i: uint = 0u; - while i < n_elts { push(t); i += 1u; } + let mut i: uint = 0; + while i < n_elts { push(t); i += 1; } } } /// Appending two generic sequences #[inline(always)] pure fn append,BT: Buildable>( - lhs: IT, rhs: IT) -> BT { + lhs: &IT, rhs: &IT) -> BT { let size_opt = lhs.size_hint().chain_ref( |sz1| rhs.size_hint().map(|sz2| *sz1+*sz2)); do build_sized_opt(size_opt) |push| { @@ -298,7 +298,7 @@ pure fn append,BT: Buildable>( /// type of sequence. #[inline(always)] pure fn copy_seq,BT: Buildable>( - v: IT) -> BT { + v: &IT) -> BT { do build_sized_opt(v.size_hint()) |push| { for v.each |x| { push(*x); } }