Skip to content

Commit f1014c4

Browse files
committed
Finish demoding iter: from_elem, copy_seq, map, append
1 parent d0333a8 commit f1014c4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libcore/iter.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ pure fn build_sized_opt<A,B: Buildable<A>>(
248248
// Functions that combine iteration and building
249249

250250
/// Apply a function to each element of an iterable and return the results
251-
fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: IT, f: fn(T) -> U) -> BU {
251+
fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: &IT, f: fn(&T) -> U) -> BU {
252252
do build_sized_opt(v.size_hint()) |push| {
253253
for v.each() |elem| {
254-
push(f(*elem));
254+
push(f(elem));
255255
}
256256
}
257257
}
@@ -275,17 +275,17 @@ pure fn from_fn<T,BT: Buildable<T>>(n_elts: uint, op: InitOp<T>) -> BT {
275275
* Creates an immutable vector of size `n_elts` and initializes the elements
276276
* to the value `t`.
277277
*/
278-
pure fn from_elem<T: Copy,BT: Buildable<T>>(n_elts: uint, t: T) -> BT {
278+
pure fn from_elem<T: Copy,BT: Buildable<T>>(n_elts: uint, +t: T) -> BT {
279279
do build_sized(n_elts) |push| {
280-
let mut i: uint = 0u;
281-
while i < n_elts { push(t); i += 1u; }
280+
let mut i: uint = 0;
281+
while i < n_elts { push(t); i += 1; }
282282
}
283283
}
284284

285285
/// Appending two generic sequences
286286
#[inline(always)]
287287
pure fn append<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>(
288-
lhs: IT, rhs: IT) -> BT {
288+
lhs: &IT, rhs: &IT) -> BT {
289289
let size_opt = lhs.size_hint().chain_ref(
290290
|sz1| rhs.size_hint().map(|sz2| *sz1+*sz2));
291291
do build_sized_opt(size_opt) |push| {
@@ -298,7 +298,7 @@ pure fn append<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>(
298298
/// type of sequence.
299299
#[inline(always)]
300300
pure fn copy_seq<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>(
301-
v: IT) -> BT {
301+
v: &IT) -> BT {
302302
do build_sized_opt(v.size_hint()) |push| {
303303
for v.each |x| { push(*x); }
304304
}

0 commit comments

Comments
 (0)