Skip to content

Commit d8ae725

Browse files
committed
---
yaml --- r: 30750 b: refs/heads/incoming c: cac5a9f h: refs/heads/master v: v3
1 parent edd4c9a commit d8ae725

File tree

3 files changed

+22
-32
lines changed

3 files changed

+22
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: d05e2ad66c7bb2418b7c746f87486d4f74180193
9+
refs/heads/incoming: cac5a9f916c07c68f9e5ea361dfa6261d978995e
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/at_vec.rs

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
33
use ptr::addr_of;
44

5-
export init_op;
6-
export capacity;
7-
export build_sized, build, build_sized_opt;
8-
export map;
9-
export from_fn, from_elem;
10-
export raw;
11-
export traits;
12-
135
/// Code for dealing with @-vectors. This is pretty incomplete, and
146
/// contains a bunch of duplication from the code for ~-vectors.
157
@@ -29,7 +21,7 @@ extern mod rusti {
2921

3022
/// Returns the number of elements the vector can hold without reallocating
3123
#[inline(always)]
32-
pure fn capacity<T>(&&v: @[const T]) -> uint {
24+
pub pure fn capacity<T>(&&v: @[const T]) -> uint {
3325
unsafe {
3426
let repr: **raw::VecRepr =
3527
::cast::reinterpret_cast(&addr_of(v));
@@ -50,8 +42,8 @@ pure fn capacity<T>(&&v: @[const T]) -> uint {
5042
* onto the vector being constructed.
5143
*/
5244
#[inline(always)]
53-
pure fn build_sized<A>(size: uint,
54-
builder: fn(push: pure fn(+v: A))) -> @[A] {
45+
pub pure fn build_sized<A>(size: uint,
46+
builder: fn(push: pure fn(+v: A))) -> @[A] {
5547
let mut vec = @[];
5648
unsafe { raw::reserve(vec, size); }
5749
builder(|+x| unsafe { raw::push(vec, move x) });
@@ -69,7 +61,7 @@ pure fn build_sized<A>(size: uint,
6961
* onto the vector being constructed.
7062
*/
7163
#[inline(always)]
72-
pure fn build<A>(builder: fn(push: pure fn(+v: A))) -> @[A] {
64+
pub pure fn build<A>(builder: fn(push: pure fn(+v: A))) -> @[A] {
7365
build_sized(4, builder)
7466
}
7567

@@ -86,14 +78,14 @@ pure fn build<A>(builder: fn(push: pure fn(+v: A))) -> @[A] {
8678
* onto the vector being constructed.
8779
*/
8880
#[inline(always)]
89-
pure fn build_sized_opt<A>(size: Option<uint>,
81+
pub pure fn build_sized_opt<A>(size: Option<uint>,
9082
builder: fn(push: pure fn(+v: A))) -> @[A] {
9183
build_sized(size.get_default(4), builder)
9284
}
9385

9486
// Appending
9587
#[inline(always)]
96-
pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
88+
pub pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
9789
do build_sized(lhs.len() + rhs.len()) |push| {
9890
for vec::each(lhs) |x| { push(*x); }
9991
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
@@ -102,7 +94,7 @@ pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
10294

10395

10496
/// Apply a function to each element of a vector and return the results
105-
pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
97+
pub pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
10698
do build_sized(v.len()) |push| {
10799
for vec::each(v) |elem| {
108100
push(f(*elem));
@@ -116,7 +108,7 @@ pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
116108
* Creates an immutable vector of size `n_elts` and initializes the elements
117109
* to the value returned by the function `op`.
118110
*/
119-
pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
111+
pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
120112
do build_sized(n_elts) |push| {
121113
let mut i: uint = 0u;
122114
while i < n_elts { push(op(i)); i += 1u; }
@@ -129,7 +121,7 @@ pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
129121
* Creates an immutable vector of size `n_elts` and initializes the elements
130122
* to the value `t`.
131123
*/
132-
pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
124+
pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
133125
do build_sized(n_elts) |push| {
134126
let mut i: uint = 0u;
135127
while i < n_elts { push(t); i += 1u; }
@@ -148,13 +140,12 @@ mod traits {
148140
}
149141

150142
#[cfg(test)]
151-
mod traits {
143+
pub mod traits {
152144
#[legacy_exports];}
153145

154-
mod raw {
155-
#[legacy_exports];
156-
type VecRepr = vec::raw::VecRepr;
157-
type SliceRepr = vec::raw::SliceRepr;
146+
pub mod raw {
147+
pub type VecRepr = vec::raw::VecRepr;
148+
pub type SliceRepr = vec::raw::SliceRepr;
158149

159150
/**
160151
* Sets the length of a vector
@@ -164,13 +155,13 @@ mod raw {
164155
* the vector is actually the specified size.
165156
*/
166157
#[inline(always)]
167-
unsafe fn set_len<T>(&&v: @[const T], new_len: uint) {
158+
pub unsafe fn set_len<T>(&&v: @[const T], new_len: uint) {
168159
let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(v));
169160
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
170161
}
171162

172163
#[inline(always)]
173-
unsafe fn push<T>(&v: @[const T], +initval: T) {
164+
pub unsafe fn push<T>(&v: @[const T], +initval: T) {
174165
let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(v));
175166
let fill = (**repr).unboxed.fill;
176167
if (**repr).unboxed.alloc > fill {
@@ -182,7 +173,7 @@ mod raw {
182173
}
183174
// This doesn't bother to make sure we have space.
184175
#[inline(always)] // really pretty please
185-
unsafe fn push_fast<T>(&v: @[const T], +initval: T) {
176+
pub unsafe fn push_fast<T>(&v: @[const T], +initval: T) {
186177
let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(v));
187178
let fill = (**repr).unboxed.fill;
188179
(**repr).unboxed.fill += sys::size_of::<T>();
@@ -191,7 +182,7 @@ mod raw {
191182
rusti::move_val_init(*p, move initval);
192183
}
193184

194-
unsafe fn push_slow<T>(&v: @[const T], +initval: T) {
185+
pub unsafe fn push_slow<T>(&v: @[const T], +initval: T) {
195186
reserve_at_least(v, v.len() + 1u);
196187
push_fast(v, move initval);
197188
}
@@ -207,7 +198,7 @@ mod raw {
207198
* * v - A vector
208199
* * n - The number of elements to reserve space for
209200
*/
210-
unsafe fn reserve<T>(&v: @[const T], n: uint) {
201+
pub unsafe fn reserve<T>(&v: @[const T], n: uint) {
211202
// Only make the (slow) call into the runtime if we have to
212203
if capacity(v) < n {
213204
let ptr = addr_of(v) as **VecRepr;
@@ -231,14 +222,14 @@ mod raw {
231222
* * v - A vector
232223
* * n - The number of elements to reserve space for
233224
*/
234-
unsafe fn reserve_at_least<T>(&v: @[const T], n: uint) {
225+
pub unsafe fn reserve_at_least<T>(&v: @[const T], n: uint) {
235226
reserve(v, uint::next_power_of_two(n));
236227
}
237228

238229
}
239230

240231
#[test]
241-
fn test() {
232+
pub fn test() {
242233
// Some code that could use that, then:
243234
fn seq_range(lo: uint, hi: uint) -> @[uint] {
244235
do build |push| {
@@ -254,7 +245,7 @@ fn test() {
254245
}
255246

256247
#[test]
257-
fn append_test() {
248+
pub fn append_test() {
258249
assert @[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6];
259250
}
260251

branches/incoming/src/libcore/core.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ mod str;
201201
mod ptr;
202202
#[legacy_exports]
203203
mod vec;
204-
#[legacy_exports]
205204
mod at_vec;
206205
#[legacy_exports]
207206
mod bool;

0 commit comments

Comments
 (0)