De-export std::{bitv, cell, timer}. Part of #3583.

This commit is contained in:
Graydon Hoare 2012-09-28 14:55:31 -07:00
parent 94f7bf98f9
commit 70ae3e7bf2
4 changed files with 12 additions and 19 deletions

View File

@ -2,8 +2,6 @@
use vec::{to_mut, from_elem};
export Bitv, from_bytes, from_bools, from_fn;
struct SmallBitv {
/// only the lowest nbits of this value are used. the rest is undefined.
mut bits: u32
@ -209,12 +207,12 @@ enum BitvVariant { Big(~BigBitv), Small(~SmallBitv) }
enum Op {Union, Intersect, Assign, Difference}
// The bitvector type
struct Bitv {
pub struct Bitv {
rep: BitvVariant,
nbits: uint
}
fn Bitv (nbits: uint, init: bool) -> Bitv {
pub fn Bitv (nbits: uint, init: bool) -> Bitv {
let rep = if nbits <= 32 {
Small(~SmallBitv(if init {!0} else {0}))
}
@ -519,7 +517,7 @@ impl Bitv {
* with the most significant bits of each byte coming first. Each
* bit becomes true if equal to 1 or false if equal to 0.
*/
fn from_bytes(bytes: &[u8]) -> Bitv {
pub fn from_bytes(bytes: &[u8]) -> Bitv {
from_fn(bytes.len() * 8, |i| {
let b = bytes[i / 8] as uint;
let offset = i % 8;
@ -530,7 +528,7 @@ fn from_bytes(bytes: &[u8]) -> Bitv {
/**
* Transform a [bool] into a bitv by converting each bool into a bit.
*/
fn from_bools(bools: &[bool]) -> Bitv {
pub fn from_bools(bools: &[bool]) -> Bitv {
from_fn(bools.len(), |i| bools[i])
}
@ -538,7 +536,7 @@ fn from_bools(bools: &[bool]) -> Bitv {
* Create a bitv of the specified length where the value at each
* index is f(index).
*/
fn from_fn(len: uint, f: fn(index: uint) -> bool) -> Bitv {
pub fn from_fn(len: uint, f: fn(index: uint) -> bool) -> Bitv {
let bitv = Bitv(len, false);
for uint::range(0, len) |i| {
bitv.set(i, f(i));

View File

@ -3,16 +3,16 @@
///
/// Similar to a mutable option type, but friendlier.
struct Cell<T> {
pub struct Cell<T> {
mut value: Option<T>
}
/// Creates a new full cell with the given value.
fn Cell<T>(+value: T) -> Cell<T> {
pub fn Cell<T>(+value: T) -> Cell<T> {
Cell { value: Some(move value) }
}
fn empty_cell<T>() -> Cell<T> {
pub fn empty_cell<T>() -> Cell<T> {
Cell { value: None }
}

View File

@ -69,9 +69,7 @@ mod uv_global_loop;
#[legacy_exports]
mod c_vec;
#[legacy_exports]
mod timer;
#[legacy_exports]
mod cell;
// Concurrency
@ -85,7 +83,6 @@ mod comm;
// Collections
#[legacy_exports]
mod bitv;
#[legacy_exports]
mod deque;

View File

@ -7,8 +7,6 @@ use uv::iotask;
use iotask::IoTask;
use comm = core::comm;
export delayed_send, sleep, recv_timeout;
/**
* Wait for timeout period then send provided value over a channel
*
@ -25,8 +23,8 @@ export delayed_send, sleep, recv_timeout;
* * ch - a channel of type T to send a `val` on
* * val - a value of type T to send over the provided `ch`
*/
fn delayed_send<T: Copy Send>(iotask: IoTask,
msecs: uint, ch: comm::Chan<T>, +val: T) {
pub fn delayed_send<T: Copy Send>(iotask: IoTask,
msecs: uint, ch: comm::Chan<T>, +val: T) {
unsafe {
let timer_done_po = core::comm::Port::<()>();
let timer_done_ch = core::comm::Chan(timer_done_po);
@ -74,7 +72,7 @@ fn delayed_send<T: Copy Send>(iotask: IoTask,
* * `iotask` - a `uv::iotask` that the tcp request will run on
* * msecs - an amount of time, in milliseconds, for the current task to block
*/
fn sleep(iotask: IoTask, msecs: uint) {
pub fn sleep(iotask: IoTask, msecs: uint) {
let exit_po = core::comm::Port::<()>();
let exit_ch = core::comm::Chan(exit_po);
delayed_send(iotask, msecs, exit_ch, ());
@ -101,7 +99,7 @@ fn sleep(iotask: IoTask, msecs: uint) {
* on the provided port in the allotted timeout period, then the result will
* be a `some(T)`. If not, then `none` will be returned.
*/
fn recv_timeout<T: Copy Send>(iotask: IoTask,
pub fn recv_timeout<T: Copy Send>(iotask: IoTask,
msecs: uint,
wait_po: comm::Port<T>) -> Option<T> {
let timeout_po = comm::Port::<()>();