diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 6388e8983d2..2973c8cc9f7 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -15,13 +15,7 @@ use core::cmp::{Eq, Ord}; use option::{Some, None}; use option = option; -export Treemap; -export init; -export insert; -export find; -export traverse; - -type Treemap = @TreeNode; +pub type Treemap = @TreeNode; enum TreeNode { Empty, @@ -29,10 +23,10 @@ enum TreeNode { } /// Create a treemap -fn init() -> Treemap { @Empty } +pub fn init() -> Treemap { @Empty } /// Insert a value into the map -fn insert(m: Treemap, +k: K, +v: V) +pub fn insert(m: Treemap, +k: K, +v: V) -> Treemap { @match m { @Empty => Node(@k, @v, @Empty, @Empty), @@ -47,7 +41,7 @@ fn insert(m: Treemap, +k: K, +v: V) } /// Find a value based on the key -fn find(m: Treemap, +k: K) -> Option { +pub fn find(m: Treemap, +k: K) -> Option { match *m { Empty => None, Node(@ref kk, @copy v, left, right) => { @@ -59,7 +53,7 @@ fn find(m: Treemap, +k: K) -> Option { } /// Visit all pairs in the map in order. -fn traverse(m: Treemap, f: fn((&K), (&V))) { +pub fn traverse(m: Treemap, f: fn((&K), (&V))) { match *m { Empty => (), /* diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 2a7019f5a58..5b0931ebdee 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -6,13 +6,13 @@ use core::option; use option::*; use option::{Some, None}; -enum List { +pub enum List { Cons(T, @List), Nil, } /// Cregate a list from a vector -fn from_vec(v: &[T]) -> @List { +pub fn from_vec(v: &[T]) -> @List { vec::foldr(v, @Nil::, |h, t| @Cons(*h, t)) } @@ -29,7 +29,7 @@ fn from_vec(v: &[T]) -> @List { * * z - The initial value * * f - The function to apply */ -fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { +pub fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, elt);} accum @@ -42,7 +42,7 @@ fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -fn find(ls: @List, f: fn((&T)) -> bool) -> Option { +pub fn find(ls: @List, f: fn((&T)) -> bool) -> Option { let mut ls = ls; loop { ls = match *ls { @@ -56,7 +56,7 @@ fn find(ls: @List, f: fn((&T)) -> bool) -> Option { } /// Returns true if a list contains an element with the given value -fn has(ls: @List, +elt: T) -> bool { +pub fn has(ls: @List, +elt: T) -> bool { for each(ls) |e| { if *e == elt { return true; } } @@ -64,7 +64,7 @@ fn has(ls: @List, +elt: T) -> bool { } /// Returns true if the list is empty -pure fn is_empty(ls: @List) -> bool { +pub pure fn is_empty(ls: @List) -> bool { match *ls { Nil => true, _ => false @@ -72,19 +72,19 @@ pure fn is_empty(ls: @List) -> bool { } /// Returns true if the list is not empty -pure fn is_not_empty(ls: @List) -> bool { +pub pure fn is_not_empty(ls: @List) -> bool { return !is_empty(ls); } /// Returns the length of a list -fn len(ls: @List) -> uint { +pub fn len(ls: @List) -> uint { let mut count = 0u; iter(ls, |_e| count += 1u); count } /// Returns all but the first element of a list -pure fn tail(ls: @List) -> @List { +pub pure fn tail(ls: @List) -> @List { match *ls { Cons(_, tl) => return tl, Nil => fail ~"list empty" @@ -92,7 +92,7 @@ pure fn tail(ls: @List) -> @List { } /// Returns the first element of a list -pure fn head(ls: @List) -> T { +pub pure fn head(ls: @List) -> T { match *ls { Cons(copy hd, _) => hd, // makes me sad @@ -101,7 +101,7 @@ pure fn head(ls: @List) -> T { } /// Appends one list to another -pure fn append(l: @List, m: @List) -> @List { +pub pure fn append(l: @List, m: @List) -> @List { match *l { Nil => return m, Cons(copy x, xs) => { @@ -120,7 +120,7 @@ pure fn push(ll: &mut @list, +vv: T) { */ /// Iterate over a list -fn iter(l: @List, f: fn((&T))) { +pub fn iter(l: @List, f: fn((&T))) { let mut cur = l; loop { cur = match *cur { @@ -134,7 +134,7 @@ fn iter(l: @List, f: fn((&T))) { } /// Iterate over a list -fn each(l: @List, f: fn((&T)) -> bool) { +pub fn each(l: @List, f: fn((&T)) -> bool) { let mut cur = l; loop { cur = match *cur { diff --git a/src/libstd/map.rs b/src/libstd/map.rs index fce75cbda75..84fee092562 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -11,16 +11,12 @@ use core::cmp::Eq; use hash::Hash; use to_bytes::IterBytes; -export HashMap, hashfn, eqfn, Set, Map, chained, set_add; -export hash_from_vec; -export vec_from_set; - /// A convenience type to treat a hashmap as a set -type Set = HashMap; +pub type Set = HashMap; -type HashMap = chained::T; +pub type HashMap = chained::T; -trait Map { +pub trait Map { /// Return the number of elements in the map pure fn size() -> uint; @@ -82,10 +78,9 @@ trait Map { } mod util { - #[legacy_exports]; - type Rational = {num: int, den: int}; // : int::positive(*.den); + pub type Rational = {num: int, den: int}; // : int::positive(*.den); - pure fn rational_leq(x: Rational, y: Rational) -> bool { + pub pure fn rational_leq(x: Rational, y: Rational) -> bool { // NB: Uses the fact that rationals have positive denominators WLOG: x.num * y.den <= y.num * x.den @@ -95,9 +90,7 @@ mod util { // FIXME (#2344): package this up and export it as a datatype usable for // external code that doesn't want to pay the cost of a box. -mod chained { - #[legacy_exports]; - export T, mk, HashMap; +pub mod chained { const initial_capacity: uint = 32u; // 2^5 @@ -113,7 +106,7 @@ mod chained { mut chains: ~[mut Option<@Entry>] } - type T = @HashMap_; + pub type T = @HashMap_; enum SearchResult { NotFound, @@ -366,7 +359,7 @@ mod chained { vec::to_mut(vec::from_elem(nchains, None)) } - fn mk() -> T { + pub fn mk() -> T { let slf: T = @HashMap_ {count: 0u, chains: chains(initial_capacity)}; slf @@ -378,18 +371,18 @@ Function: hashmap Construct a hashmap. */ -fn HashMap() +pub fn HashMap() -> HashMap { chained::mk() } /// Convenience function for adding keys to a hashmap with nil type keys -fn set_add(set: Set, +key: K) -> bool { +pub fn set_add(set: Set, +key: K) -> bool { set.insert(key, ()) } /// Convert a set into a vector. -fn vec_from_set(s: Set) -> ~[T] { +pub fn vec_from_set(s: Set) -> ~[T] { do vec::build_sized(s.size()) |push| { for s.each_key() |k| { push(k); @@ -398,7 +391,7 @@ fn vec_from_set(s: Set) -> ~[T] { } /// Construct a hashmap from a vector -fn hash_from_vec( +pub fn hash_from_vec( items: &[(K, V)]) -> HashMap { let map = HashMap(); for vec::each(items) |item| { @@ -517,7 +510,6 @@ impl @Mut>: #[cfg(test)] mod tests { - #[legacy_exports]; #[test] fn test_simple() { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 4d5eefec053..4831ac993a2 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -77,11 +77,8 @@ mod comm; mod bitv; mod deque; -#[legacy_exports] mod fun_treemap; -#[legacy_exports] mod list; -#[legacy_exports] mod map; mod rope; mod smallintmap;