diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-10-06 12:26:12 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-10-07 09:09:50 +0200 |
| commit | f9fbd86f52cf597b85359ade1ca60b8d6ebf7286 (patch) | |
| tree | d6f0cdd039642052f3ccb4ba8f3b9821bb7cbaaf /src/lib/vec.rs | |
| parent | 4709038d641ad009b44ed2bf5980fa3a252d6927 (diff) | |
| download | rust-f9fbd86f52cf597b85359ade1ca60b8d6ebf7286.tar.gz rust-f9fbd86f52cf597b85359ade1ca60b8d6ebf7286.zip | |
Parse and typecheck by-value and by-ref arg specs
Add sprinkle && throughout the compiler to make it typecheck again. Issue #1008
Diffstat (limited to 'src/lib/vec.rs')
| -rw-r--r-- | src/lib/vec.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/vec.rs b/src/lib/vec.rs index 59f29d40d7c..bc4334a06bc 100644 --- a/src/lib/vec.rs +++ b/src/lib/vec.rs @@ -191,6 +191,17 @@ fn map<@T, @U>(f: block(T) -> U, v: [mutable? T]) -> [U] { } ret result; } +// FIXME This is needed to make working with by-value functions a bit less +// painful. We should come up with a better solution. +fn map_imm<@T, @U>(f: block(+T) -> U, v: [mutable? T]) -> [U] { + let result = []; + reserve(result, len(v)); + for elem: T in v { + let elem2 = elem; // satisfies alias checker + result += [f(elem2)]; + } + ret result; +} fn map2<@T, @U, @V>(f: block(T, U) -> V, v0: [T], v1: [U]) -> [V] { let v0_len = len::<T>(v0); |
