Skip to content

Commit b742c0f

Browse files
committed
---
yaml --- r: 2268 b: refs/heads/master c: 66e5dfb h: refs/heads/master v: v3
1 parent e36a792 commit b742c0f

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: e300b8047f57920f518ab32eadef12d8e6047c5d
2+
refs/heads/master: 66e5dfbde6ce7a84158d39f4b19acc420b1f7c5a

trunk/src/lib/_vec.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ type vbuf = rustrt.vbuf;
66

77
type operator2[T,U,V] = fn(&T, &U) -> V;
88

9+
type array[T] = vec[mutable? T];
10+
911
native "rust" mod rustrt {
1012
type vbuf;
1113

@@ -43,7 +45,7 @@ fn alloc_mut[T](uint n_elts) -> vec[mutable T] {
4345
ret rustrt.vec_alloc_mut[vec[mutable T], T](n_elts);
4446
}
4547

46-
fn refcount[T](vec[mutable? T] v) -> uint {
48+
fn refcount[T](array[T] v) -> uint {
4749
auto r = rustrt.refcount[T](v);
4850
if (r == dbg.const_refcount) {
4951
ret r;
@@ -116,29 +118,29 @@ fn init_elt_mut[T](&T t, uint n_elts) -> vec[mutable T] {
116118
ret v;
117119
}
118120

119-
fn buf[T](vec[mutable? T] v) -> vbuf {
121+
fn buf[T](array[T] v) -> vbuf {
120122
ret rustrt.vec_buf[T](v, 0u);
121123
}
122124

123-
fn len[T](vec[mutable? T] v) -> uint {
125+
fn len[T](array[T] v) -> uint {
124126
ret rustrt.vec_len[T](v);
125127
}
126128

127-
fn len_set[T](vec[mutable? T] v, uint n) {
129+
fn len_set[T](array[T] v, uint n) {
128130
rustrt.vec_len_set[T](v, n);
129131
}
130132

131-
fn buf_off[T](vec[mutable? T] v, uint offset) -> vbuf {
133+
fn buf_off[T](array[T] v, uint offset) -> vbuf {
132134
check (offset < len[T](v));
133135
ret rustrt.vec_buf[T](v, offset);
134136
}
135137

136-
fn print_debug_info[T](vec[mutable? T] v) {
138+
fn print_debug_info[T](array[T] v) {
137139
rustrt.vec_print_debug_info[T](v);
138140
}
139141

140142
// Returns the last element of v.
141-
fn last[T](vec[mutable? T] v) -> option.t[T] {
143+
fn last[T](array[T] v) -> option.t[T] {
142144
auto l = len[T](v);
143145
if (l == 0u) {
144146
ret none[T];
@@ -147,7 +149,7 @@ fn last[T](vec[mutable? T] v) -> option.t[T] {
147149
}
148150

149151
// Returns elements from [start..end) from v.
150-
fn slice[T](vec[mutable? T] v, uint start, uint end) -> vec[T] {
152+
fn slice[T](array[T] v, uint start, uint end) -> vec[T] {
151153
check (start <= end);
152154
check (end <= len[T](v));
153155
auto result = alloc[T](end - start);
@@ -159,15 +161,15 @@ fn slice[T](vec[mutable? T] v, uint start, uint end) -> vec[T] {
159161
ret result;
160162
}
161163

162-
fn shift[T](&mutable vec[mutable? T] v) -> T {
164+
fn shift[T](&mutable array[T] v) -> T {
163165
auto ln = len[T](v);
164166
check(ln > 0u);
165167
auto e = v.(0);
166168
v = slice[T](v, 1u, ln);
167169
ret e;
168170
}
169171

170-
fn pop[T](&mutable vec[mutable? T] v) -> T {
172+
fn pop[T](&mutable array[T] v) -> T {
171173
auto ln = len[T](v);
172174
check(ln > 0u);
173175
ln -= 1u;
@@ -176,18 +178,18 @@ fn pop[T](&mutable vec[mutable? T] v) -> T {
176178
ret e;
177179
}
178180

179-
fn push[T](&mutable vec[mutable? T] v, &T t) {
181+
fn push[T](&mutable array[T] v, &T t) {
180182
v += vec(t);
181183
}
182184

183-
fn unshift[T](&mutable vec[mutable? T] v, &T t) {
185+
fn unshift[T](&mutable array[T] v, &T t) {
184186
auto res = alloc[T](len[T](v) + 1u);
185187
res += vec(t);
186188
res += v;
187189
v = res;
188190
}
189191

190-
fn grow[T](&mutable vec[mutable? T] v, uint n, &T initval) {
192+
fn grow[T](&mutable array[T] v, uint n, &T initval) {
191193
let uint i = n;
192194
while (i > 0u) {
193195
i -= 1u;
@@ -203,16 +205,15 @@ fn grow_set[T](&mutable vec[mutable T] v, uint index, &T initval, &T val) {
203205
v.(index) = val;
204206
}
205207

206-
fn map[T, U](&option.operator[T,U] f, &vec[mutable? T] v) -> vec[U] {
208+
fn map[T, U](&option.operator[T,U] f, &array[T] v) -> vec[U] {
207209
let vec[U] u = alloc[U](len[T](v));
208210
for (T ve in v) {
209211
u += vec(f(ve));
210212
}
211213
ret u;
212214
}
213215

214-
fn map2[T,U,V](&operator2[T,U,V] f, &vec[mutable? T] v0, &vec[mutable? U] v1)
215-
-> vec[V] {
216+
fn map2[T,U,V](&operator2[T,U,V] f, &array[T] v0, &array[U] v1) -> vec[V] {
216217
auto v0_len = len[T](v0);
217218
if (v0_len != len[U](v1)) {
218219
fail;
@@ -228,7 +229,7 @@ fn map2[T,U,V](&operator2[T,U,V] f, &vec[mutable? T] v0, &vec[mutable? U] v1)
228229
ret u;
229230
}
230231

231-
fn find[T](fn (&T) -> bool f, &vec[mutable? T] v) -> option.t[T] {
232+
fn find[T](fn (&T) -> bool f, &array[T] v) -> option.t[T] {
232233
for (T elt in v) {
233234
if (f(elt)) {
234235
ret some[T](elt);

0 commit comments

Comments
 (0)