Skip to content

Commit cac5a9f

Browse files
committed
libcore: De-export core::at_vec
1 parent d05e2ad commit cac5a9f

File tree

2 files changed

+21
-31
lines changed

2 files changed

+21
-31
lines changed

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

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)