Convert more core types to camel case

This commit is contained in:
Brian Anderson 2012-08-14 16:54:13 -07:00
parent 8be0f665bc
commit 74c69e1053
67 changed files with 457 additions and 427 deletions

View File

@ -15,7 +15,7 @@ export unsafe;
#[abi = "cdecl"] #[abi = "cdecl"]
extern mod rustrt { extern mod rustrt {
fn vec_reserve_shared_actual(++t: *sys::TypeDesc, fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
++v: **vec::unsafe::vec_repr, ++v: **vec::unsafe::VecRepr,
++n: libc::size_t); ++n: libc::size_t);
} }
@ -25,13 +25,13 @@ extern mod rusti {
} }
/// A function used to initialize the elements of a vector /// A function used to initialize the elements of a vector
type init_op<T> = fn(uint) -> T; type InitOp<T> = fn(uint) -> T;
/// Returns the number of elements the vector can hold without reallocating /// Returns the number of elements the vector can hold without reallocating
#[inline(always)] #[inline(always)]
pure fn capacity<T>(&&v: @[const T]) -> uint { pure fn capacity<T>(&&v: @[const T]) -> uint {
unsafe { unsafe {
let repr: **unsafe::vec_repr = let repr: **unsafe::VecRepr =
::unsafe::reinterpret_cast(addr_of(v)); ::unsafe::reinterpret_cast(addr_of(v));
(**repr).alloc / sys::size_of::<T>() (**repr).alloc / sys::size_of::<T>()
} }
@ -103,7 +103,7 @@ pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
* Creates an immutable vector of size `n_elts` and initializes the elements * Creates an immutable vector of size `n_elts` and initializes the elements
* to the value returned by the function `op`. * to the value returned by the function `op`.
*/ */
pure fn from_fn<T>(n_elts: uint, op: init_op<T>) -> @[T] { pure fn from_fn<T>(n_elts: uint, op: InitOp<T>) -> @[T] {
do build_sized(n_elts) |push| { do build_sized(n_elts) |push| {
let mut i: uint = 0u; let mut i: uint = 0u;
while i < n_elts { push(op(i)); i += 1u; } while i < n_elts { push(op(i)); i += 1u; }
@ -133,8 +133,8 @@ impl<T: copy> @[T]: add<&[const T],@[T]> {
mod unsafe { mod unsafe {
type vec_repr = vec::unsafe::vec_repr; type VecRepr = vec::unsafe::VecRepr;
type slice_repr = vec::unsafe::slice_repr; type SliceRepr = vec::unsafe::SliceRepr;
/** /**
* Sets the length of a vector * Sets the length of a vector
@ -145,13 +145,13 @@ mod unsafe {
*/ */
#[inline(always)] #[inline(always)]
unsafe fn set_len<T>(&&v: @[const T], new_len: uint) { unsafe fn set_len<T>(&&v: @[const T], new_len: uint) {
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); let repr: **VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
(**repr).fill = new_len * sys::size_of::<T>(); (**repr).fill = new_len * sys::size_of::<T>();
} }
#[inline(always)] #[inline(always)]
unsafe fn push<T>(&v: @[const T], +initval: T) { unsafe fn push<T>(&v: @[const T], +initval: T) {
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); let repr: **VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
let fill = (**repr).fill; let fill = (**repr).fill;
if (**repr).alloc > fill { if (**repr).alloc > fill {
push_fast(v, initval); push_fast(v, initval);
@ -163,7 +163,7 @@ mod unsafe {
// This doesn't bother to make sure we have space. // This doesn't bother to make sure we have space.
#[inline(always)] // really pretty please #[inline(always)] // really pretty please
unsafe fn push_fast<T>(&v: @[const T], +initval: T) { unsafe fn push_fast<T>(&v: @[const T], +initval: T) {
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); let repr: **VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
let fill = (**repr).fill; let fill = (**repr).fill;
(**repr).fill += sys::size_of::<T>(); (**repr).fill += sys::size_of::<T>();
let p = ptr::addr_of((**repr).data); let p = ptr::addr_of((**repr).data);
@ -190,7 +190,7 @@ mod unsafe {
unsafe fn reserve<T>(&v: @[const T], n: uint) { unsafe fn reserve<T>(&v: @[const T], n: uint) {
// Only make the (slow) call into the runtime if we have to // Only make the (slow) call into the runtime if we have to
if capacity(v) < n { if capacity(v) < n {
let ptr = addr_of(v) as **vec_repr; let ptr = addr_of(v) as **VecRepr;
rustrt::vec_reserve_shared_actual(sys::get_type_desc::<T>(), rustrt::vec_reserve_shared_actual(sys::get_type_desc::<T>(),
ptr, n as libc::size_t); ptr, n as libc::size_t);
} }

View File

@ -27,7 +27,7 @@
* ~~~ * ~~~
*/ */
import either::either; import either::Either;
import libc::size_t; import libc::size_t;
export port; export port;
@ -222,7 +222,7 @@ fn peek_(p: *rust_port) -> bool {
/// Receive on one of two ports /// Receive on one of two ports
fn select2<A: send, B: send>(p_a: port<A>, p_b: port<B>) fn select2<A: send, B: send>(p_a: port<A>, p_b: port<B>)
-> either<A, B> { -> Either<A, B> {
let ports = ~[(**p_a).po, (**p_b).po]; let ports = ~[(**p_a).po, (**p_b).po];
let yield = 0u, yieldp = ptr::addr_of(yield); let yield = 0u, yieldp = ptr::addr_of(yield);
@ -246,9 +246,9 @@ fn select2<A: send, B: send>(p_a: port<A>, p_b: port<B>)
assert resport != ptr::null(); assert resport != ptr::null();
if resport == (**p_a).po { if resport == (**p_a).po {
either::left(recv(p_a)) either::Left(recv(p_a))
} else if resport == (**p_b).po { } else if resport == (**p_b).po {
either::right(recv(p_b)) either::Right(recv(p_b))
} else { } else {
fail ~"unexpected result from rust_port_select"; fail ~"unexpected result from rust_port_select";
} }
@ -355,11 +355,11 @@ fn test_select2_available() {
send(ch_a, ~"a"); send(ch_a, ~"a");
assert select2(po_a, po_b) == either::left(~"a"); assert select2(po_a, po_b) == either::Left(~"a");
send(ch_b, ~"b"); send(ch_b, ~"b");
assert select2(po_a, po_b) == either::right(~"b"); assert select2(po_a, po_b) == either::Right(~"b");
} }
#[test] #[test]
@ -375,14 +375,14 @@ fn test_select2_rendezvous() {
send(ch_a, ~"a"); send(ch_a, ~"a");
}; };
assert select2(po_a, po_b) == either::left(~"a"); assert select2(po_a, po_b) == either::Left(~"a");
do task::spawn { do task::spawn {
for iter::repeat(10u) { task::yield() } for iter::repeat(10u) { task::yield() }
send(ch_b, ~"b"); send(ch_b, ~"b");
}; };
assert select2(po_a, po_b) == either::right(~"b"); assert select2(po_a, po_b) == either::Right(~"b");
} }
} }
@ -413,8 +413,8 @@ fn test_select2_stress() {
let mut bs = 0; let mut bs = 0;
for iter::repeat(msgs * times * 2u) { for iter::repeat(msgs * times * 2u) {
match select2(po_a, po_b) { match select2(po_a, po_b) {
either::left(~"a") => as += 1, either::Left(~"a") => as += 1,
either::right(~"b") => bs += 1, either::Right(~"b") => bs += 1,
_ => fail ~"test_select_2_stress failed" _ => fail ~"test_select_2_stress failed"
} }
} }

View File

@ -68,6 +68,7 @@ export priv;
// Built-in-type support modules // Built-in-type support modules
/// Operations and constants for `int` /// Operations and constants for `int`
#[warn(non_camel_case_types)]
#[path = "int-template"] #[path = "int-template"]
mod int { mod int {
import inst::{ hash, pow }; import inst::{ hash, pow };
@ -77,6 +78,7 @@ mod int {
} }
/// Operations and constants for `i8` /// Operations and constants for `i8`
#[warn(non_camel_case_types)]
#[path = "int-template"] #[path = "int-template"]
mod i8 { mod i8 {
#[path = "i8.rs"] #[path = "i8.rs"]
@ -84,6 +86,7 @@ mod i8 {
} }
/// Operations and constants for `i16` /// Operations and constants for `i16`
#[warn(non_camel_case_types)]
#[path = "int-template"] #[path = "int-template"]
mod i16 { mod i16 {
#[path = "i16.rs"] #[path = "i16.rs"]
@ -91,6 +94,7 @@ mod i16 {
} }
/// Operations and constants for `i32` /// Operations and constants for `i32`
#[warn(non_camel_case_types)]
#[path = "int-template"] #[path = "int-template"]
mod i32 { mod i32 {
#[path = "i32.rs"] #[path = "i32.rs"]
@ -98,6 +102,7 @@ mod i32 {
} }
/// Operations and constants for `i64` /// Operations and constants for `i64`
#[warn(non_camel_case_types)]
#[path = "int-template"] #[path = "int-template"]
mod i64 { mod i64 {
#[path = "i64.rs"] #[path = "i64.rs"]
@ -105,6 +110,7 @@ mod i64 {
} }
/// Operations and constants for `uint` /// Operations and constants for `uint`
#[warn(non_camel_case_types)]
#[path = "uint-template"] #[path = "uint-template"]
mod uint { mod uint {
import inst::{ import inst::{
@ -119,6 +125,7 @@ mod uint {
} }
/// Operations and constants for `u8` /// Operations and constants for `u8`
#[warn(non_camel_case_types)]
#[path = "uint-template"] #[path = "uint-template"]
mod u8 { mod u8 {
import inst::is_ascii; import inst::is_ascii;
@ -129,6 +136,7 @@ mod u8 {
} }
/// Operations and constants for `u16` /// Operations and constants for `u16`
#[warn(non_camel_case_types)]
#[path = "uint-template"] #[path = "uint-template"]
mod u16 { mod u16 {
#[path = "u16.rs"] #[path = "u16.rs"]
@ -136,6 +144,7 @@ mod u16 {
} }
/// Operations and constants for `u32` /// Operations and constants for `u32`
#[warn(non_camel_case_types)]
#[path = "uint-template"] #[path = "uint-template"]
mod u32 { mod u32 {
#[path = "u32.rs"] #[path = "u32.rs"]
@ -143,6 +152,7 @@ mod u32 {
} }
/// Operations and constants for `u64` /// Operations and constants for `u64`
#[warn(non_camel_case_types)]
#[path = "uint-template"] #[path = "uint-template"]
mod u64 { mod u64 {
#[path = "u64.rs"] #[path = "u64.rs"]
@ -150,15 +160,25 @@ mod u64 {
} }
#[warn(non_camel_case_types)]
mod box; mod box;
#[warn(non_camel_case_types)]
mod char; mod char;
#[warn(non_camel_case_types)]
mod float; mod float;
#[warn(non_camel_case_types)]
mod f32; mod f32;
#[warn(non_camel_case_types)]
mod f64; mod f64;
#[warn(non_camel_case_types)]
mod str; mod str;
#[warn(non_camel_case_types)]
mod ptr; mod ptr;
#[warn(non_camel_case_types)]
mod vec; mod vec;
#[warn(non_camel_case_types)]
mod at_vec; mod at_vec;
#[warn(non_camel_case_types)]
mod bool; mod bool;
#[warn(non_camel_case_types)] #[warn(non_camel_case_types)]
mod tuple; mod tuple;
@ -173,7 +193,9 @@ mod cmp;
mod num; mod num;
#[warn(non_camel_case_types)] #[warn(non_camel_case_types)]
mod hash; mod hash;
#[warn(non_camel_case_types)]
mod either; mod either;
#[warn(non_camel_case_types)]
mod iter; mod iter;
#[warn(non_camel_case_types)] #[warn(non_camel_case_types)]
mod logging; mod logging;
@ -193,18 +215,23 @@ mod util;
// Data structure modules // Data structure modules
#[warn(non_camel_case_types)]
mod dvec; mod dvec;
#[path="iter-trait"] #[path="iter-trait"]
#[warn(non_camel_case_types)]
mod dvec_iter { mod dvec_iter {
#[path = "dvec.rs"] #[path = "dvec.rs"]
mod inst; mod inst;
} }
#[warn(non_camel_case_types)]
mod dlist; mod dlist;
#[path="iter-trait"] #[path="iter-trait"]
#[warn(non_camel_case_types)]
mod dlist_iter { mod dlist_iter {
#[path ="dlist.rs"] #[path ="dlist.rs"]
mod inst; mod inst;
} }
#[warn(non_camel_case_types)]
mod send_map; mod send_map;
// Concurrency // Concurrency

View File

@ -6,25 +6,25 @@ import option::{some, none};
import option = option::option; import option = option::option;
import Path = path::Path; import Path = path::Path;
import tuple::{TupleOps, ExtendedTupleOps}; import tuple::{TupleOps, ExtendedTupleOps};
import str::{str_slice, unique_str}; import str::{StrSlice, UniqueStr};
import vec::{const_vector, copyable_vector, immutable_vector}; import vec::{ConstVector, CopyableVector, ImmutableVector};
import vec::{immutable_copyable_vector, iter_trait_extensions}; import vec::{ImmutableCopyableVector, IterTraitExtensions};
import iter::{base_iter, extended_iter, copyable_iter, times, timesi}; import iter::{BaseIter, ExtendedIter, CopyableIter, Times, TimesIx};
import num::Num; import num::Num;
import ptr::ptr; import ptr::Ptr;
import to_str::ToStr; import to_str::ToStr;
export Path, option, some, none, unreachable; export Path, option, some, none, unreachable;
export extensions; export extensions;
// The following exports are the extension impls for numeric types // The following exports are the extension impls for numeric types
export Num, times, timesi; export Num, Times, TimesIx;
// The following exports are the common traits // The following exports are the common traits
export str_slice, unique_str; export StrSlice, UniqueStr;
export const_vector, copyable_vector, immutable_vector; export ConstVector, CopyableVector, ImmutableVector;
export immutable_copyable_vector, iter_trait_extensions; export ImmutableCopyableVector, IterTraitExtensions;
export base_iter, copyable_iter, extended_iter; export BaseIter, CopyableIter, ExtendedIter;
export TupleOps, ExtendedTupleOps; export TupleOps, ExtendedTupleOps;
export ptr; export Ptr;
export ToStr; export ToStr;
// The following exports are the core operators and kinds // The following exports are the core operators and kinds

View File

@ -8,25 +8,25 @@
* Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate. * Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
*/ */
export dlist, dlist_node; export DList, dlist, dlist_node;
export new_dlist, from_elem, from_vec, extensions; export new_dlist, from_elem, from_vec, extensions;
type dlist_link<T> = option<dlist_node<T>>; type DListLink<T> = option<DListNode<T>>;
enum dlist_node<T> = @{ enum DListNode<T> = @{
data: T, data: T,
mut linked: bool, // for assertions mut linked: bool, // for assertions
mut prev: dlist_link<T>, mut prev: DListLink<T>,
mut next: dlist_link<T> mut next: DListLink<T>
}; };
enum dlist<T> = @{ enum DList<T> = @{
mut size: uint, mut size: uint,
mut hd: dlist_link<T>, mut hd: DListLink<T>,
mut tl: dlist_link<T>, mut tl: DListLink<T>,
}; };
priv impl<T> dlist_node<T> { priv impl<T> DListNode<T> {
pure fn assert_links() { pure fn assert_links() {
match self.next { match self.next {
some(neighbour) => match neighbour.prev { some(neighbour) => match neighbour.prev {
@ -49,26 +49,26 @@ priv impl<T> dlist_node<T> {
} }
} }
impl<T> dlist_node<T> { impl<T> DListNode<T> {
/// Get the next node in the list, if there is one. /// Get the next node in the list, if there is one.
pure fn next_link() -> option<dlist_node<T>> { pure fn next_link() -> option<DListNode<T>> {
self.assert_links(); self.assert_links();
self.next self.next
} }
/// Get the next node in the list, failing if there isn't one. /// Get the next node in the list, failing if there isn't one.
pure fn next_node() -> dlist_node<T> { pure fn next_node() -> DListNode<T> {
match self.next_link() { match self.next_link() {
some(nobe) => nobe, some(nobe) => nobe,
none => fail ~"This dlist node has no next neighbour." none => fail ~"This dlist node has no next neighbour."
} }
} }
/// Get the previous node in the list, if there is one. /// Get the previous node in the list, if there is one.
pure fn prev_link() -> option<dlist_node<T>> { pure fn prev_link() -> option<DListNode<T>> {
self.assert_links(); self.assert_links();
self.prev self.prev
} }
/// Get the previous node in the list, failing if there isn't one. /// Get the previous node in the list, failing if there isn't one.
pure fn prev_node() -> dlist_node<T> { pure fn prev_node() -> DListNode<T> {
match self.prev_link() { match self.prev_link() {
some(nobe) => nobe, some(nobe) => nobe,
none => fail ~"This dlist node has no previous neighbour." none => fail ~"This dlist node has no previous neighbour."
@ -77,24 +77,24 @@ impl<T> dlist_node<T> {
} }
/// Creates a new dlist node with the given data. /// Creates a new dlist node with the given data.
pure fn new_dlist_node<T>(+data: T) -> dlist_node<T> { pure fn new_dlist_node<T>(+data: T) -> DListNode<T> {
dlist_node(@{data: data, mut linked: false, DListNode(@{data: data, mut linked: false,
mut prev: none, mut next: none}) mut prev: none, mut next: none})
} }
/// Creates a new, empty dlist. /// Creates a new, empty dlist.
pure fn new_dlist<T>() -> dlist<T> { pure fn new_dlist<T>() -> DList<T> {
dlist(@{mut size: 0, mut hd: none, mut tl: none}) DList(@{mut size: 0, mut hd: none, mut tl: none})
} }
/// Creates a new dlist with a single element /// Creates a new dlist with a single element
pure fn from_elem<T>(+data: T) -> dlist<T> { pure fn from_elem<T>(+data: T) -> DList<T> {
let list = new_dlist(); let list = new_dlist();
unchecked { list.push(data); } unchecked { list.push(data); }
list list
} }
fn from_vec<T: copy>(+vec: &[T]) -> dlist<T> { fn from_vec<T: copy>(+vec: &[T]) -> DList<T> {
do vec::foldl(new_dlist(), vec) |list,data| { do vec::foldl(new_dlist(), vec) |list,data| {
list.push(data); // Iterating left-to-right -- add newly to the tail. list.push(data); // Iterating left-to-right -- add newly to the tail.
list list
@ -103,7 +103,7 @@ fn from_vec<T: copy>(+vec: &[T]) -> dlist<T> {
/// Produce a list from a list of lists, leaving no elements behind in the /// Produce a list from a list of lists, leaving no elements behind in the
/// input. O(number of sub-lists). /// input. O(number of sub-lists).
fn concat<T>(lists: dlist<dlist<T>>) -> dlist<T> { fn concat<T>(lists: DList<DList<T>>) -> DList<T> {
let result = new_dlist(); let result = new_dlist();
while !lists.is_empty() { while !lists.is_empty() {
result.append(lists.pop().get()); result.append(lists.pop().get());
@ -111,12 +111,12 @@ fn concat<T>(lists: dlist<dlist<T>>) -> dlist<T> {
result result
} }
priv impl<T> dlist<T> { priv impl<T> DList<T> {
pure fn new_link(-data: T) -> dlist_link<T> { pure fn new_link(-data: T) -> DListLink<T> {
some(dlist_node(@{data: data, mut linked: true, some(DListNode(@{data: data, mut linked: true,
mut prev: none, mut next: none})) mut prev: none, mut next: none}))
} }
pure fn assert_mine(nobe: dlist_node<T>) { pure fn assert_mine(nobe: DListNode<T>) {
// These asserts could be stronger if we had node-root back-pointers, // These asserts could be stronger if we had node-root back-pointers,
// but those wouldn't allow for O(1) append. // but those wouldn't allow for O(1) append.
if self.size == 0 { if self.size == 0 {
@ -130,7 +130,7 @@ priv impl<T> dlist<T> {
fail ~"That node isn't on this dlist." fail ~"That node isn't on this dlist."
} }
} }
fn make_mine(nobe: dlist_node<T>) { fn make_mine(nobe: DListNode<T>) {
if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked { if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked {
fail ~"Cannot insert node that's already on a dlist!" fail ~"Cannot insert node that's already on a dlist!"
} }
@ -139,7 +139,7 @@ priv impl<T> dlist<T> {
// Link two nodes together. If either of them are 'none', also sets // Link two nodes together. If either of them are 'none', also sets
// the head and/or tail pointers appropriately. // the head and/or tail pointers appropriately.
#[inline(always)] #[inline(always)]
fn link(+before: dlist_link<T>, +after: dlist_link<T>) { fn link(+before: DListLink<T>, +after: DListLink<T>) {
match before { match before {
some(neighbour) => neighbour.next = after, some(neighbour) => neighbour.next = after,
none => self.hd = after none => self.hd = after
@ -150,7 +150,7 @@ priv impl<T> dlist<T> {
} }
} }
// Remove a node from the list. // Remove a node from the list.
fn unlink(nobe: dlist_node<T>) { fn unlink(nobe: DListNode<T>) {
self.assert_mine(nobe); self.assert_mine(nobe);
assert self.size > 0; assert self.size > 0;
self.link(nobe.prev, nobe.next); self.link(nobe.prev, nobe.next);
@ -160,24 +160,24 @@ priv impl<T> dlist<T> {
self.size -= 1; self.size -= 1;
} }
fn add_head(+nobe: dlist_link<T>) { fn add_head(+nobe: DListLink<T>) {
self.link(nobe, self.hd); // Might set tail too. self.link(nobe, self.hd); // Might set tail too.
self.hd = nobe; self.hd = nobe;
self.size += 1; self.size += 1;
} }
fn add_tail(+nobe: dlist_link<T>) { fn add_tail(+nobe: DListLink<T>) {
self.link(self.tl, nobe); // Might set head too. self.link(self.tl, nobe); // Might set head too.
self.tl = nobe; self.tl = nobe;
self.size += 1; self.size += 1;
} }
fn insert_left(nobe: dlist_link<T>, neighbour: dlist_node<T>) { fn insert_left(nobe: DListLink<T>, neighbour: DListNode<T>) {
self.assert_mine(neighbour); self.assert_mine(neighbour);
assert self.size > 0; assert self.size > 0;
self.link(neighbour.prev, nobe); self.link(neighbour.prev, nobe);
self.link(nobe, some(neighbour)); self.link(nobe, some(neighbour));
self.size += 1; self.size += 1;
} }
fn insert_right(neighbour: dlist_node<T>, nobe: dlist_link<T>) { fn insert_right(neighbour: DListNode<T>, nobe: DListLink<T>) {
self.assert_mine(neighbour); self.assert_mine(neighbour);
assert self.size > 0; assert self.size > 0;
self.link(nobe, neighbour.next); self.link(nobe, neighbour.next);
@ -186,7 +186,7 @@ priv impl<T> dlist<T> {
} }
} }
impl<T> dlist<T> { impl<T> DList<T> {
/// Get the size of the list. O(1). /// Get the size of the list. O(1).
pure fn len() -> uint { self.size } pure fn len() -> uint { self.size }
/// Returns true if the list is empty. O(1). /// Returns true if the list is empty. O(1).
@ -202,7 +202,7 @@ impl<T> dlist<T> {
* Add data to the head of the list, and get the new containing * Add data to the head of the list, and get the new containing
* node. O(1). * node. O(1).
*/ */
fn push_head_n(+data: T) -> dlist_node<T> { fn push_head_n(+data: T) -> DListNode<T> {
let mut nobe = self.new_link(data); let mut nobe = self.new_link(data);
self.add_head(nobe); self.add_head(nobe);
option::get(nobe) option::get(nobe)
@ -215,7 +215,7 @@ impl<T> dlist<T> {
* Add data to the tail of the list, and get the new containing * Add data to the tail of the list, and get the new containing
* node. O(1). * node. O(1).
*/ */
fn push_n(+data: T) -> dlist_node<T> { fn push_n(+data: T) -> DListNode<T> {
let mut nobe = self.new_link(data); let mut nobe = self.new_link(data);
self.add_tail(nobe); self.add_tail(nobe);
option::get(nobe) option::get(nobe)
@ -224,14 +224,14 @@ impl<T> dlist<T> {
* Insert data into the middle of the list, left of the given node. * Insert data into the middle of the list, left of the given node.
* O(1). * O(1).
*/ */
fn insert_before(+data: T, neighbour: dlist_node<T>) { fn insert_before(+data: T, neighbour: DListNode<T>) {
self.insert_left(self.new_link(data), neighbour); self.insert_left(self.new_link(data), neighbour);
} }
/** /**
* Insert an existing node in the middle of the list, left of the * Insert an existing node in the middle of the list, left of the
* given node. O(1). * given node. O(1).
*/ */
fn insert_n_before(nobe: dlist_node<T>, neighbour: dlist_node<T>) { fn insert_n_before(nobe: DListNode<T>, neighbour: DListNode<T>) {
self.make_mine(nobe); self.make_mine(nobe);
self.insert_left(some(nobe), neighbour); self.insert_left(some(nobe), neighbour);
} }
@ -239,7 +239,7 @@ impl<T> dlist<T> {
* Insert data in the middle of the list, left of the given node, * Insert data in the middle of the list, left of the given node,
* and get its containing node. O(1). * and get its containing node. O(1).
*/ */
fn insert_before_n(+data: T, neighbour: dlist_node<T>) -> dlist_node<T> { fn insert_before_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
let mut nobe = self.new_link(data); let mut nobe = self.new_link(data);
self.insert_left(nobe, neighbour); self.insert_left(nobe, neighbour);
option::get(nobe) option::get(nobe)
@ -248,14 +248,14 @@ impl<T> dlist<T> {
* Insert data into the middle of the list, right of the given node. * Insert data into the middle of the list, right of the given node.
* O(1). * O(1).
*/ */
fn insert_after(+data: T, neighbour: dlist_node<T>) { fn insert_after(+data: T, neighbour: DListNode<T>) {
self.insert_right(neighbour, self.new_link(data)); self.insert_right(neighbour, self.new_link(data));
} }
/** /**
* Insert an existing node in the middle of the list, right of the * Insert an existing node in the middle of the list, right of the
* given node. O(1). * given node. O(1).
*/ */
fn insert_n_after(nobe: dlist_node<T>, neighbour: dlist_node<T>) { fn insert_n_after(nobe: DListNode<T>, neighbour: DListNode<T>) {
self.make_mine(nobe); self.make_mine(nobe);
self.insert_right(neighbour, some(nobe)); self.insert_right(neighbour, some(nobe));
} }
@ -263,38 +263,38 @@ impl<T> dlist<T> {
* Insert data in the middle of the list, right of the given node, * Insert data in the middle of the list, right of the given node,
* and get its containing node. O(1). * and get its containing node. O(1).
*/ */
fn insert_after_n(+data: T, neighbour: dlist_node<T>) -> dlist_node<T> { fn insert_after_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
let mut nobe = self.new_link(data); let mut nobe = self.new_link(data);
self.insert_right(neighbour, nobe); self.insert_right(neighbour, nobe);
option::get(nobe) option::get(nobe)
} }
/// Remove a node from the head of the list. O(1). /// Remove a node from the head of the list. O(1).
fn pop_n() -> option<dlist_node<T>> { fn pop_n() -> option<DListNode<T>> {
let hd = self.peek_n(); let hd = self.peek_n();
hd.map(|nobe| self.unlink(nobe)); hd.map(|nobe| self.unlink(nobe));
hd hd
} }
/// Remove a node from the tail of the list. O(1). /// Remove a node from the tail of the list. O(1).
fn pop_tail_n() -> option<dlist_node<T>> { fn pop_tail_n() -> option<DListNode<T>> {
let tl = self.peek_tail_n(); let tl = self.peek_tail_n();
tl.map(|nobe| self.unlink(nobe)); tl.map(|nobe| self.unlink(nobe));
tl tl
} }
/// Get the node at the list's head. O(1). /// Get the node at the list's head. O(1).
pure fn peek_n() -> option<dlist_node<T>> { self.hd } pure fn peek_n() -> option<DListNode<T>> { self.hd }
/// Get the node at the list's tail. O(1). /// Get the node at the list's tail. O(1).
pure fn peek_tail_n() -> option<dlist_node<T>> { self.tl } pure fn peek_tail_n() -> option<DListNode<T>> { self.tl }
/// Get the node at the list's head, failing if empty. O(1). /// Get the node at the list's head, failing if empty. O(1).
pure fn head_n() -> dlist_node<T> { pure fn head_n() -> DListNode<T> {
match self.hd { match self.hd {
some(nobe) => nobe, some(nobe) => nobe,
none => fail ~"Attempted to get the head of an empty dlist." none => fail ~"Attempted to get the head of an empty dlist."
} }
} }
/// Get the node at the list's tail, failing if empty. O(1). /// Get the node at the list's tail, failing if empty. O(1).
pure fn tail_n() -> dlist_node<T> { pure fn tail_n() -> DListNode<T> {
match self.tl { match self.tl {
some(nobe) => nobe, some(nobe) => nobe,
none => fail ~"Attempted to get the tail of an empty dlist." none => fail ~"Attempted to get the tail of an empty dlist."
@ -302,13 +302,13 @@ impl<T> dlist<T> {
} }
/// Remove a node from anywhere in the list. O(1). /// Remove a node from anywhere in the list. O(1).
fn remove(nobe: dlist_node<T>) { self.unlink(nobe); } fn remove(nobe: DListNode<T>) { self.unlink(nobe); }
/** /**
* Empty another list onto the end of this list, joining this list's tail * Empty another list onto the end of this list, joining this list's tail
* to the other list's head. O(1). * to the other list's head. O(1).
*/ */
fn append(them: dlist<T>) { fn append(them: DList<T>) {
if box::ptr_eq(*self, *them) { if box::ptr_eq(*self, *them) {
fail ~"Cannot append a dlist to itself!" fail ~"Cannot append a dlist to itself!"
} }
@ -325,7 +325,7 @@ impl<T> dlist<T> {
* Empty another list onto the start of this list, joining the other * Empty another list onto the start of this list, joining the other
* list's tail to this list's head. O(1). * list's tail to this list's head. O(1).
*/ */
fn prepend(them: dlist<T>) { fn prepend(them: DList<T>) {
if box::ptr_eq(*self, *them) { if box::ptr_eq(*self, *them) {
fail ~"Cannot prepend a dlist to itself!" fail ~"Cannot prepend a dlist to itself!"
} }
@ -363,7 +363,7 @@ impl<T> dlist<T> {
} }
/// Iterate over nodes. /// Iterate over nodes.
pure fn each_node(f: fn(dlist_node<T>) -> bool) { pure fn each_node(f: fn(DListNode<T>) -> bool) {
let mut link = self.peek_n(); let mut link = self.peek_n();
while link.is_some() { while link.is_some() {
let nobe = link.get(); let nobe = link.get();
@ -415,7 +415,7 @@ impl<T> dlist<T> {
} }
} }
impl<T: copy> dlist<T> { impl<T: copy> DList<T> {
/// Remove data from the head of the list. O(1). /// Remove data from the head of the list. O(1).
fn pop() -> option<T> { self.pop_n().map (|nobe| nobe.data) } fn pop() -> option<T> { self.pop_n().map (|nobe| nobe.data) }
/// Remove data from the tail of the list. O(1). /// Remove data from the tail of the list. O(1).

View File

@ -12,6 +12,7 @@
import unsafe::reinterpret_cast; import unsafe::reinterpret_cast;
import ptr::null; import ptr::null;
export DVec;
export dvec; export dvec;
export from_elem; export from_elem;
export from_vec; export from_vec;
@ -49,36 +50,36 @@ export unwrap;
* pointers achieved about 103 million pushes/second. Using an option * pointers achieved about 103 million pushes/second. Using an option
* type could only produce 47 million pushes/second. * type could only produce 47 million pushes/second.
*/ */
type dvec_<A> = { type DVec_<A> = {
mut data: ~[mut A] mut data: ~[mut A]
}; };
enum dvec<A> { enum DVec<A> {
dvec_(dvec_<A>) DVec_(DVec_<A>)
} }
/// Creates a new, empty dvec /// Creates a new, empty dvec
fn dvec<A>() -> dvec<A> { fn dvec<A>() -> DVec<A> {
dvec_({mut data: ~[mut]}) DVec_({mut data: ~[mut]})
} }
/// Creates a new dvec with a single element /// Creates a new dvec with a single element
fn from_elem<A>(+e: A) -> dvec<A> { fn from_elem<A>(+e: A) -> DVec<A> {
dvec_({mut data: ~[mut e]}) DVec_({mut data: ~[mut e]})
} }
/// Creates a new dvec with the contents of a vector /// Creates a new dvec with the contents of a vector
fn from_vec<A>(+v: ~[mut A]) -> dvec<A> { fn from_vec<A>(+v: ~[mut A]) -> DVec<A> {
dvec_({mut data: v}) DVec_({mut data: v})
} }
/// Consumes the vector and returns its contents /// Consumes the vector and returns its contents
fn unwrap<A>(+d: dvec<A>) -> ~[mut A] { fn unwrap<A>(+d: DVec<A>) -> ~[mut A] {
let dvec_({data: v}) <- d; let DVec_({data: v}) <- d;
return v; return v;
} }
priv impl<A> dvec<A> { priv impl<A> DVec<A> {
pure fn check_not_borrowed() { pure fn check_not_borrowed() {
unsafe { unsafe {
let data: *() = unsafe::reinterpret_cast(self.data); let data: *() = unsafe::reinterpret_cast(self.data);
@ -110,7 +111,7 @@ priv impl<A> dvec<A> {
// In theory, most everything should work with any A, but in practice // In theory, most everything should work with any A, but in practice
// almost nothing works without the copy bound due to limitations // almost nothing works without the copy bound due to limitations
// around closures. // around closures.
impl<A> dvec<A> { impl<A> DVec<A> {
/// Reserves space for N elements /// Reserves space for N elements
fn reserve(count: uint) { fn reserve(count: uint) {
vec::reserve(self.data, count) vec::reserve(self.data, count)
@ -191,7 +192,7 @@ impl<A> dvec<A> {
} }
} }
impl<A: copy> dvec<A> { impl<A: copy> DVec<A> {
/** /**
* Append all elements of a vector to the end of the list * Append all elements of a vector to the end of the list
* *
@ -308,7 +309,7 @@ impl<A: copy> dvec<A> {
} }
} }
impl<A:copy> dvec<A>: index<uint,A> { impl<A:copy> DVec<A>: index<uint,A> {
pure fn index(&&idx: uint) -> A { pure fn index(&&idx: uint) -> A {
self.get_elt(idx) self.get_elt(idx)
} }

View File

@ -7,13 +7,13 @@
import result::result; import result::result;
/// The either type /// The either type
enum either<T, U> { enum Either<T, U> {
left(T), Left(T),
right(U) Right(U)
} }
fn either<T, U, V>(f_left: fn((&T)) -> V, fn either<T, U, V>(f_left: fn((&T)) -> V,
f_right: fn((&U)) -> V, value: &either<T, U>) -> V { f_right: fn((&U)) -> V, value: &Either<T, U>) -> V {
/*! /*!
* Applies a function based on the given either value * Applies a function based on the given either value
* *
@ -23,38 +23,38 @@ fn either<T, U, V>(f_left: fn((&T)) -> V,
*/ */
match *value { match *value {
left(ref l) => f_left(l), Left(ref l) => f_left(l),
right(ref r) => f_right(r) Right(ref r) => f_right(r)
} }
} }
fn lefts<T: copy, U>(eithers: &[either<T, U>]) -> ~[T] { fn lefts<T: copy, U>(eithers: &[Either<T, U>]) -> ~[T] {
//! Extracts from a vector of either all the left values //! Extracts from a vector of either all the left values
let mut result: ~[T] = ~[]; let mut result: ~[T] = ~[];
for vec::each(eithers) |elt| { for vec::each(eithers) |elt| {
match elt { match elt {
left(l) => vec::push(result, l), Left(l) => vec::push(result, l),
_ => { /* fallthrough */ } _ => { /* fallthrough */ }
} }
} }
return result; return result;
} }
fn rights<T, U: copy>(eithers: &[either<T, U>]) -> ~[U] { fn rights<T, U: copy>(eithers: &[Either<T, U>]) -> ~[U] {
//! Extracts from a vector of either all the right values //! Extracts from a vector of either all the right values
let mut result: ~[U] = ~[]; let mut result: ~[U] = ~[];
for vec::each(eithers) |elt| { for vec::each(eithers) |elt| {
match elt { match elt {
right(r) => vec::push(result, r), Right(r) => vec::push(result, r),
_ => { /* fallthrough */ } _ => { /* fallthrough */ }
} }
} }
return result; return result;
} }
fn partition<T: copy, U: copy>(eithers: &[either<T, U>]) fn partition<T: copy, U: copy>(eithers: &[Either<T, U>])
-> {lefts: ~[T], rights: ~[U]} { -> {lefts: ~[T], rights: ~[U]} {
/*! /*!
* Extracts from a vector of either all the left values and right values * Extracts from a vector of either all the left values and right values
@ -67,23 +67,23 @@ fn partition<T: copy, U: copy>(eithers: &[either<T, U>])
let mut rights: ~[U] = ~[]; let mut rights: ~[U] = ~[];
for vec::each(eithers) |elt| { for vec::each(eithers) |elt| {
match elt { match elt {
left(l) => vec::push(lefts, l), Left(l) => vec::push(lefts, l),
right(r) => vec::push(rights, r) Right(r) => vec::push(rights, r)
} }
} }
return {lefts: lefts, rights: rights}; return {lefts: lefts, rights: rights};
} }
pure fn flip<T: copy, U: copy>(eith: &either<T, U>) -> either<U, T> { pure fn flip<T: copy, U: copy>(eith: &Either<T, U>) -> Either<U, T> {
//! Flips between left and right of a given either //! Flips between left and right of a given either
match *eith { match *eith {
right(r) => left(r), Right(r) => Left(r),
left(l) => right(l) Left(l) => Right(l)
} }
} }
pure fn to_result<T: copy, U: copy>(eith: &either<T, U>) -> result<U, T> { pure fn to_result<T: copy, U: copy>(eith: &Either<T, U>) -> result<U, T> {
/*! /*!
* Converts either::t to a result::t * Converts either::t to a result::t
* *
@ -92,26 +92,26 @@ pure fn to_result<T: copy, U: copy>(eith: &either<T, U>) -> result<U, T> {
*/ */
match *eith { match *eith {
right(r) => result::ok(r), Right(r) => result::ok(r),
left(l) => result::err(l) Left(l) => result::err(l)
} }
} }
pure fn is_left<T, U>(eith: &either<T, U>) -> bool { pure fn is_left<T, U>(eith: &Either<T, U>) -> bool {
//! Checks whether the given value is a left //! Checks whether the given value is a left
match *eith { left(_) => true, _ => false } match *eith { Left(_) => true, _ => false }
} }
pure fn is_right<T, U>(eith: &either<T, U>) -> bool { pure fn is_right<T, U>(eith: &Either<T, U>) -> bool {
//! Checks whether the given value is a right //! Checks whether the given value is a right
match *eith { right(_) => true, _ => false } match *eith { Right(_) => true, _ => false }
} }
#[test] #[test]
fn test_either_left() { fn test_either_left() {
let val = left(10); let val = Left(10);
fn f_left(x: &int) -> bool { *x == 10 } fn f_left(x: &int) -> bool { *x == 10 }
fn f_right(_x: &uint) -> bool { false } fn f_right(_x: &uint) -> bool { false }
assert (either(f_left, f_right, &val)); assert (either(f_left, f_right, &val));
@ -119,7 +119,7 @@ fn test_either_left() {
#[test] #[test]
fn test_either_right() { fn test_either_right() {
let val = right(10u); let val = Right(10u);
fn f_left(_x: &int) -> bool { false } fn f_left(_x: &int) -> bool { false }
fn f_right(x: &uint) -> bool { *x == 10u } fn f_right(x: &uint) -> bool { *x == 10u }
assert (either(f_left, f_right, &val)); assert (either(f_left, f_right, &val));
@ -127,49 +127,49 @@ fn test_either_right() {
#[test] #[test]
fn test_lefts() { fn test_lefts() {
let input = ~[left(10), right(11), left(12), right(13), left(14)]; let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)];
let result = lefts(input); let result = lefts(input);
assert (result == ~[10, 12, 14]); assert (result == ~[10, 12, 14]);
} }
#[test] #[test]
fn test_lefts_none() { fn test_lefts_none() {
let input: ~[either<int, int>] = ~[right(10), right(10)]; let input: ~[Either<int, int>] = ~[Right(10), Right(10)];
let result = lefts(input); let result = lefts(input);
assert (vec::len(result) == 0u); assert (vec::len(result) == 0u);
} }
#[test] #[test]
fn test_lefts_empty() { fn test_lefts_empty() {
let input: ~[either<int, int>] = ~[]; let input: ~[Either<int, int>] = ~[];
let result = lefts(input); let result = lefts(input);
assert (vec::len(result) == 0u); assert (vec::len(result) == 0u);
} }
#[test] #[test]
fn test_rights() { fn test_rights() {
let input = ~[left(10), right(11), left(12), right(13), left(14)]; let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)];
let result = rights(input); let result = rights(input);
assert (result == ~[11, 13]); assert (result == ~[11, 13]);
} }
#[test] #[test]
fn test_rights_none() { fn test_rights_none() {
let input: ~[either<int, int>] = ~[left(10), left(10)]; let input: ~[Either<int, int>] = ~[Left(10), Left(10)];
let result = rights(input); let result = rights(input);
assert (vec::len(result) == 0u); assert (vec::len(result) == 0u);
} }
#[test] #[test]
fn test_rights_empty() { fn test_rights_empty() {
let input: ~[either<int, int>] = ~[]; let input: ~[Either<int, int>] = ~[];
let result = rights(input); let result = rights(input);
assert (vec::len(result) == 0u); assert (vec::len(result) == 0u);
} }
#[test] #[test]
fn test_partition() { fn test_partition() {
let input = ~[left(10), right(11), left(12), right(13), left(14)]; let input = ~[Left(10), Right(11), Left(12), Right(13), Left(14)];
let result = partition(input); let result = partition(input);
assert (result.lefts[0] == 10); assert (result.lefts[0] == 10);
assert (result.lefts[1] == 12); assert (result.lefts[1] == 12);
@ -180,7 +180,7 @@ fn test_partition() {
#[test] #[test]
fn test_partition_no_lefts() { fn test_partition_no_lefts() {
let input: ~[either<int, int>] = ~[right(10), right(11)]; let input: ~[Either<int, int>] = ~[Right(10), Right(11)];
let result = partition(input); let result = partition(input);
assert (vec::len(result.lefts) == 0u); assert (vec::len(result.lefts) == 0u);
assert (vec::len(result.rights) == 2u); assert (vec::len(result.rights) == 2u);
@ -188,7 +188,7 @@ fn test_partition_no_lefts() {
#[test] #[test]
fn test_partition_no_rights() { fn test_partition_no_rights() {
let input: ~[either<int, int>] = ~[left(10), left(11)]; let input: ~[Either<int, int>] = ~[Left(10), Left(11)];
let result = partition(input); let result = partition(input);
assert (vec::len(result.lefts) == 2u); assert (vec::len(result.lefts) == 2u);
assert (vec::len(result.rights) == 0u); assert (vec::len(result.rights) == 0u);
@ -196,7 +196,7 @@ fn test_partition_no_rights() {
#[test] #[test]
fn test_partition_empty() { fn test_partition_empty() {
let input: ~[either<int, int>] = ~[]; let input: ~[Either<int, int>] = ~[];
let result = partition(input); let result = partition(input);
assert (vec::len(result.lefts) == 0u); assert (vec::len(result.lefts) == 0u);
assert (vec::len(result.rights) == 0u); assert (vec::len(result.rights) == 0u);

View File

@ -15,7 +15,7 @@
* ~~~ * ~~~
*/ */
import either::either; import either::Either;
import pipes::recv; import pipes::recv;
export future; export future;
@ -32,7 +32,7 @@ export future_pipe;
#[doc = "The future type"] #[doc = "The future type"]
enum future<A> = { enum future<A> = {
mut v: either<@A, fn@() -> A> mut v: Either<@A, fn@() -> A>
}; };
/// Methods on the `future` type /// Methods on the `future` type
@ -60,7 +60,7 @@ fn from_value<A>(+val: A) -> future<A> {
*/ */
future({ future({
mut v: either::left(@val) mut v: either::Left(@val)
}) })
} }
@ -97,7 +97,7 @@ fn from_fn<A>(f: fn@() -> A) -> future<A> {
*/ */
future({ future({
mut v: either::right(f) mut v: either::Right(f)
}) })
} }
@ -124,10 +124,10 @@ fn with<A,B>(future: &future<A>, blk: fn((&A)) -> B) -> B {
//! Work with the value without copying it //! Work with the value without copying it
let v = match copy future.v { let v = match copy future.v {
either::left(v) => v, either::Left(v) => v,
either::right(f) => { either::Right(f) => {
let v = @f(); let v = @f();
future.v = either::left(v); future.v = either::Left(v);
v v
} }
}; };

View File

@ -88,7 +88,7 @@ impl T: num::Num {
static pure fn from_int(n: int) -> T { return n as T; } static pure fn from_int(n: int) -> T { return n as T; }
} }
impl T: iter::times { impl T: iter::Times {
#[inline(always)] #[inline(always)]
#[doc = "A convenience form for basic iteration. Given a variable `x` \ #[doc = "A convenience form for basic iteration. Given a variable `x` \
of any numeric type, the expression `for x.times { /* anything */ }` \ of any numeric type, the expression `for x.times { /* anything */ }` \
@ -108,7 +108,7 @@ impl T: iter::times {
} }
} }
impl T: iter::timesi { impl T: iter::TimesIx {
#[inline(always)] #[inline(always)]
/// Like `times`, but provides an index /// Like `times`, but provides an index
fn timesi(it: fn(uint) -> bool) { fn timesi(it: fn(uint) -> bool) {
@ -255,7 +255,7 @@ fn test_interfaces() {
#[test] #[test]
fn test_times() { fn test_times() {
import iter::times; import iter::Times;
let ten = 10 as T; let ten = 10 as T;
let mut accum = 0; let mut accum = 0;
for ten.times { accum += 1; } for ten.times { accum += 1; }
@ -266,6 +266,6 @@ fn test_times() {
#[should_fail] #[should_fail]
#[ignore(cfg(windows))] #[ignore(cfg(windows))]
fn test_times_negative() { fn test_times_negative() {
import iter::times; import iter::Times;
for (-10).times { log(error, ~"nope!"); } for (-10).times { log(error, ~"nope!"); }
} }

View File

@ -6,7 +6,7 @@ Basic input/output
import result::result; import result::result;
import dvec::dvec; import dvec::{DVec, dvec};
import libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t}; import libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t};
import libc::consts::os::posix88::*; import libc::consts::os::posix88::*;
import libc::consts::os::extra::*; import libc::consts::os::extra::*;
@ -657,7 +657,7 @@ fn stderr() -> Writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
fn print(s: &str) { stdout().write_str(s); } fn print(s: &str) { stdout().write_str(s); }
fn println(s: &str) { stdout().write_line(s); } fn println(s: &str) { stdout().write_line(s); }
type MemBuffer = @{buf: dvec<u8>, mut pos: uint}; type MemBuffer = @{buf: DVec<u8>, mut pos: uint};
impl MemBuffer: Writer { impl MemBuffer: Writer {
fn write(v: &[const u8]) { fn write(v: &[const u8]) {

View File

@ -5,12 +5,12 @@
import inst::{IMPL_T, EACH, SIZE_HINT}; import inst::{IMPL_T, EACH, SIZE_HINT};
export extensions; export extensions;
impl<A> IMPL_T<A>: iter::base_iter<A> { impl<A> IMPL_T<A>: iter::BaseIter<A> {
fn each(blk: fn(A) -> bool) { EACH(self, blk) } fn each(blk: fn(A) -> bool) { EACH(self, blk) }
fn size_hint() -> option<uint> { SIZE_HINT(self) } fn size_hint() -> option<uint> { SIZE_HINT(self) }
} }
impl<A> IMPL_T<A>: iter::extended_iter<A> { impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
fn eachi(blk: fn(uint, A) -> bool) { iter::eachi(self, blk) } fn eachi(blk: fn(uint, A) -> bool) { iter::eachi(self, blk) }
fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) } fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) }
fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) } fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) }
@ -24,7 +24,7 @@ impl<A> IMPL_T<A>: iter::extended_iter<A> {
} }
} }
impl<A: copy> IMPL_T<A>: iter::copyable_iter<A> { impl<A: copy> IMPL_T<A>: iter::CopyableIter<A> {
fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] { fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred) iter::filter_to_vec(self, pred)
} }

View File

@ -1,4 +1,5 @@
type IMPL_T<A> = dlist::dlist<A>; #[allow(non_camel_case_types)]
type IMPL_T<A> = dlist::DList<A>;
/** /**
* Iterates through the current contents. * Iterates through the current contents.

View File

@ -1,4 +1,5 @@
type IMPL_T<A> = dvec::dvec<A>; #[allow(non_camel_case_types)]
type IMPL_T<A> = dvec::DVec<A>;
/** /**
* Iterates through the current contents. * Iterates through the current contents.

View File

@ -1,9 +1,9 @@
trait base_iter<A> { trait BaseIter<A> {
fn each(blk: fn(A) -> bool); fn each(blk: fn(A) -> bool);
fn size_hint() -> option<uint>; fn size_hint() -> option<uint>;
} }
trait extended_iter<A> { trait ExtendedIter<A> {
fn eachi(blk: fn(uint, A) -> bool); fn eachi(blk: fn(uint, A) -> bool);
fn all(blk: fn(A) -> bool) -> bool; fn all(blk: fn(A) -> bool) -> bool;
fn any(blk: fn(A) -> bool) -> bool; fn any(blk: fn(A) -> bool) -> bool;
@ -13,14 +13,14 @@ trait extended_iter<A> {
fn position(f: fn(A) -> bool) -> option<uint>; fn position(f: fn(A) -> bool) -> option<uint>;
} }
trait times { trait Times {
fn times(it: fn() -> bool); fn times(it: fn() -> bool);
} }
trait timesi{ trait TimesIx{
fn timesi(it: fn(uint) -> bool); fn timesi(it: fn(uint) -> bool);
} }
trait copyable_iter<A:copy> { trait CopyableIter<A:copy> {
fn filter_to_vec(pred: fn(A) -> bool) -> ~[A]; fn filter_to_vec(pred: fn(A) -> bool) -> ~[A];
fn map_to_vec<B>(op: fn(A) -> B) -> ~[B]; fn map_to_vec<B>(op: fn(A) -> B) -> ~[B];
fn to_vec() -> ~[A]; fn to_vec() -> ~[A];
@ -29,7 +29,7 @@ trait copyable_iter<A:copy> {
fn find(p: fn(A) -> bool) -> option<A>; fn find(p: fn(A) -> bool) -> option<A>;
} }
fn eachi<A,IA:base_iter<A>>(self: IA, blk: fn(uint, A) -> bool) { fn eachi<A,IA:BaseIter<A>>(self: IA, blk: fn(uint, A) -> bool) {
let mut i = 0u; let mut i = 0u;
for self.each |a| { for self.each |a| {
if !blk(i, a) { break; } if !blk(i, a) { break; }
@ -37,21 +37,21 @@ fn eachi<A,IA:base_iter<A>>(self: IA, blk: fn(uint, A) -> bool) {
} }
} }
fn all<A,IA:base_iter<A>>(self: IA, blk: fn(A) -> bool) -> bool { fn all<A,IA:BaseIter<A>>(self: IA, blk: fn(A) -> bool) -> bool {
for self.each |a| { for self.each |a| {
if !blk(a) { return false; } if !blk(a) { return false; }
} }
return true; return true;
} }
fn any<A,IA:base_iter<A>>(self: IA, blk: fn(A) -> bool) -> bool { fn any<A,IA:BaseIter<A>>(self: IA, blk: fn(A) -> bool) -> bool {
for self.each |a| { for self.each |a| {
if blk(a) { return true; } if blk(a) { return true; }
} }
return false; return false;
} }
fn filter_to_vec<A:copy,IA:base_iter<A>>(self: IA, fn filter_to_vec<A:copy,IA:BaseIter<A>>(self: IA,
prd: fn(A) -> bool) -> ~[A] { prd: fn(A) -> bool) -> ~[A] {
let mut result = ~[]; let mut result = ~[];
self.size_hint().iter(|hint| vec::reserve(result, hint)); self.size_hint().iter(|hint| vec::reserve(result, hint));
@ -61,7 +61,7 @@ fn filter_to_vec<A:copy,IA:base_iter<A>>(self: IA,
return result; return result;
} }
fn map_to_vec<A:copy,B,IA:base_iter<A>>(self: IA, op: fn(A) -> B) -> ~[B] { fn map_to_vec<A:copy,B,IA:BaseIter<A>>(self: IA, op: fn(A) -> B) -> ~[B] {
let mut result = ~[]; let mut result = ~[];
self.size_hint().iter(|hint| vec::reserve(result, hint)); self.size_hint().iter(|hint| vec::reserve(result, hint));
for self.each |a| { for self.each |a| {
@ -70,7 +70,7 @@ fn map_to_vec<A:copy,B,IA:base_iter<A>>(self: IA, op: fn(A) -> B) -> ~[B] {
return result; return result;
} }
fn flat_map_to_vec<A:copy,B:copy,IA:base_iter<A>,IB:base_iter<B>>( fn flat_map_to_vec<A:copy,B:copy,IA:BaseIter<A>,IB:BaseIter<B>>(
self: IA, op: fn(A) -> IB) -> ~[B] { self: IA, op: fn(A) -> IB) -> ~[B] {
let mut result = ~[]; let mut result = ~[];
@ -82,7 +82,7 @@ fn flat_map_to_vec<A:copy,B:copy,IA:base_iter<A>,IB:base_iter<B>>(
return result; return result;
} }
fn foldl<A,B,IA:base_iter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B { fn foldl<A,B,IA:BaseIter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
let mut b <- b0; let mut b <- b0;
for self.each |a| { for self.each |a| {
b = blk(b, a); b = blk(b, a);
@ -90,18 +90,18 @@ fn foldl<A,B,IA:base_iter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
return b; return b;
} }
fn to_vec<A:copy,IA:base_iter<A>>(self: IA) -> ~[A] { fn to_vec<A:copy,IA:BaseIter<A>>(self: IA) -> ~[A] {
foldl::<A,~[A],IA>(self, ~[], |r, a| vec::append(r, ~[a])) foldl::<A,~[A],IA>(self, ~[], |r, a| vec::append(r, ~[a]))
} }
fn contains<A,IA:base_iter<A>>(self: IA, x: A) -> bool { fn contains<A,IA:BaseIter<A>>(self: IA, x: A) -> bool {
for self.each |a| { for self.each |a| {
if a == x { return true; } if a == x { return true; }
} }
return false; return false;
} }
fn count<A,IA:base_iter<A>>(self: IA, x: A) -> uint { fn count<A,IA:BaseIter<A>>(self: IA, x: A) -> uint {
do foldl(self, 0u) |count, value| { do foldl(self, 0u) |count, value| {
if value == x { if value == x {
count + 1u count + 1u
@ -111,7 +111,7 @@ fn count<A,IA:base_iter<A>>(self: IA, x: A) -> uint {
} }
} }
fn position<A,IA:base_iter<A>>(self: IA, f: fn(A) -> bool) fn position<A,IA:BaseIter<A>>(self: IA, f: fn(A) -> bool)
-> option<uint> { -> option<uint> {
let mut i = 0; let mut i = 0;
for self.each |a| { for self.each |a| {
@ -133,7 +133,7 @@ fn repeat(times: uint, blk: fn() -> bool) {
} }
} }
fn min<A:copy,IA:base_iter<A>>(self: IA) -> A { fn min<A:copy,IA:BaseIter<A>>(self: IA) -> A {
match do foldl::<A,option<A>,IA>(self, none) |a, b| { match do foldl::<A,option<A>,IA>(self, none) |a, b| {
match a { match a {
some(a_) if a_ < b => { some(a_) if a_ < b => {
@ -149,7 +149,7 @@ fn min<A:copy,IA:base_iter<A>>(self: IA) -> A {
} }
} }
fn max<A:copy,IA:base_iter<A>>(self: IA) -> A { fn max<A:copy,IA:BaseIter<A>>(self: IA) -> A {
match do foldl::<A,option<A>,IA>(self, none) |a, b| { match do foldl::<A,option<A>,IA>(self, none) |a, b| {
match a { match a {
some(a_) if a_ > b => { some(a_) if a_ > b => {

View File

@ -177,16 +177,16 @@ mod global_env {
do priv::weaken_task |weak_po| { do priv::weaken_task |weak_po| {
loop { loop {
match comm::select2(msg_po, weak_po) { match comm::select2(msg_po, weak_po) {
either::left(MsgGetEnv(n, resp_ch)) => { either::Left(MsgGetEnv(n, resp_ch)) => {
comm::send(resp_ch, impl::getenv(n)) comm::send(resp_ch, impl::getenv(n))
} }
either::left(MsgSetEnv(n, v, resp_ch)) => { either::Left(MsgSetEnv(n, v, resp_ch)) => {
comm::send(resp_ch, impl::setenv(n, v)) comm::send(resp_ch, impl::setenv(n, v))
} }
either::left(MsgEnv(resp_ch)) => { either::Left(MsgEnv(resp_ch)) => {
comm::send(resp_ch, impl::env()) comm::send(resp_ch, impl::env())
} }
either::right(_) => break either::Right(_) => break
} }
} }
} }

View File

@ -77,7 +77,7 @@ bounded and unbounded protocols allows for less code duplication.
#[forbid(deprecated_pattern)]; #[forbid(deprecated_pattern)];
import unsafe::{forget, reinterpret_cast, transmute}; import unsafe::{forget, reinterpret_cast, transmute};
import either::{either, left, right}; import either::{Either, Left, Right};
import option::unwrap; import option::unwrap;
// Things used by code generated by the pipe compiler. // Things used by code generated by the pipe compiler.
@ -658,15 +658,15 @@ this case, `select2` may return either `left` or `right`.
fn select2<A: send, Ab: send, B: send, Bb: send>( fn select2<A: send, Ab: send, B: send, Bb: send>(
+a: recv_packet_buffered<A, Ab>, +a: recv_packet_buffered<A, Ab>,
+b: recv_packet_buffered<B, Bb>) +b: recv_packet_buffered<B, Bb>)
-> either<(option<A>, recv_packet_buffered<B, Bb>), -> Either<(option<A>, recv_packet_buffered<B, Bb>),
(recv_packet_buffered<A, Ab>, option<B>)> (recv_packet_buffered<A, Ab>, option<B>)>
{ {
let i = wait_many([a.header(), b.header()]/_); let i = wait_many([a.header(), b.header()]/_);
unsafe { unsafe {
match i { match i {
0 => left((try_recv(a), b)), 0 => Left((try_recv(a), b)),
1 => right((a, try_recv(b))), 1 => Right((a, try_recv(b))),
_ => fail ~"select2 return an invalid packet" _ => fail ~"select2 return an invalid packet"
} }
} }
@ -687,10 +687,10 @@ fn selecti<T: selectable>(endpoints: &[T]) -> uint {
} }
/// Returns 0 or 1 depending on which endpoint is ready to receive /// Returns 0 or 1 depending on which endpoint is ready to receive
fn select2i<A: selectable, B: selectable>(a: &A, b: &B) -> either<(), ()> { fn select2i<A: selectable, B: selectable>(a: &A, b: &B) -> Either<(), ()> {
match wait_many([a.header(), b.header()]/_) { match wait_many([a.header(), b.header()]/_) {
0 => left(()), 0 => Left(()),
1 => right(()), 1 => Right(()),
_ => fail ~"wait returned unexpected index" _ => fail ~"wait returned unexpected index"
} }
} }
@ -1117,28 +1117,28 @@ fn shared_chan<T:send>(+c: chan<T>) -> shared_chan<T> {
/// Receive a message from one of two endpoints. /// Receive a message from one of two endpoints.
trait select2<T: send, U: send> { trait select2<T: send, U: send> {
/// Receive a message or return `none` if a connection closes. /// Receive a message or return `none` if a connection closes.
fn try_select() -> either<option<T>, option<U>>; fn try_select() -> Either<option<T>, option<U>>;
/// Receive a message or fail if a connection closes. /// Receive a message or fail if a connection closes.
fn select() -> either<T, U>; fn select() -> Either<T, U>;
} }
impl<T: send, U: send, Left: selectable recv<T>, Right: selectable recv<U>> impl<T: send, U: send, Left: selectable recv<T>, Right: selectable recv<U>>
(Left, Right): select2<T, U> { (Left, Right): select2<T, U> {
fn select() -> either<T, U> { fn select() -> Either<T, U> {
match self { match self {
(lp, rp) => match select2i(&lp, &rp) { (lp, rp) => match select2i(&lp, &rp) {
left(()) => left (lp.recv()), Left(()) => Left (lp.recv()),
right(()) => right(rp.recv()) Right(()) => Right(rp.recv())
} }
} }
} }
fn try_select() -> either<option<T>, option<U>> { fn try_select() -> Either<option<T>, option<U>> {
match self { match self {
(lp, rp) => match select2i(&lp, &rp) { (lp, rp) => match select2i(&lp, &rp) {
left(()) => left (lp.try_recv()), Left(()) => Left (lp.try_recv()),
right(()) => right(rp.try_recv()) Right(()) => Right(rp.try_recv())
} }
} }
} }
@ -1204,7 +1204,7 @@ mod test {
c1.send(~"abc"); c1.send(~"abc");
match (p1, p2).select() { match (p1, p2).select() {
right(_) => fail, Right(_) => fail,
_ => () _ => ()
} }

View File

@ -16,7 +16,7 @@ export to_uint;
export ref_eq; export ref_eq;
export buf_len; export buf_len;
export position; export position;
export ptr; export Ptr;
import libc::{c_void, size_t}; import libc::{c_void, size_t};
@ -156,13 +156,13 @@ fn ref_eq<T>(thing: &a/T, other: &b/T) -> bool {
to_uint(thing) == to_uint(other) to_uint(thing) == to_uint(other)
} }
trait ptr { trait Ptr {
pure fn is_null() -> bool; pure fn is_null() -> bool;
pure fn is_not_null() -> bool; pure fn is_not_null() -> bool;
} }
/// Extension methods for pointers /// Extension methods for pointers
impl<T> *T: ptr { impl<T> *T: Ptr {
/// Returns true if the pointer is equal to the null pointer. /// Returns true if the pointer is equal to the null pointer.
pure fn is_null() -> bool { is_null(self) } pure fn is_null() -> bool { is_null(self) }

View File

@ -1,6 +1,6 @@
//! A type representing either success or failure //! A type representing either success or failure
import either::either; import either::Either;
/// The result type /// The result type
enum result<T, U> { enum result<T, U> {
@ -59,10 +59,10 @@ pure fn is_err<T, U>(res: result<T, U>) -> bool {
* `ok` result variants are converted to `either::right` variants, `err` * `ok` result variants are converted to `either::right` variants, `err`
* result variants are converted to `either::left`. * result variants are converted to `either::left`.
*/ */
pure fn to_either<T: copy, U: copy>(res: result<U, T>) -> either<T, U> { pure fn to_either<T: copy, U: copy>(res: result<U, T>) -> Either<T, U> {
match res { match res {
ok(res) => either::right(res), ok(res) => either::Right(res),
err(fail_) => either::left(fail_) err(fail_) => either::Left(fail_)
} }
} }

View File

@ -10,28 +10,28 @@ Sendable hash maps. Very much a work in progress.
* *
* The hash should concentrate entropy in the lower bits. * The hash should concentrate entropy in the lower bits.
*/ */
type hashfn<K> = pure fn~(K) -> uint; type HashFn<K> = pure fn~(K) -> uint;
type eqfn<K> = pure fn~(K, K) -> bool; type EqFn<K> = pure fn~(K, K) -> bool;
/// Open addressing with linear probing. /// Open addressing with linear probing.
mod linear { mod linear {
export linear_map, linear_map_with_capacity, public_methods; export LinearMap, linear_map, linear_map_with_capacity, public_methods;
const initial_capacity: uint = 32u; // 2^5 const initial_capacity: uint = 32u; // 2^5
type bucket<K,V> = {hash: uint, key: K, value: V}; type Bucket<K,V> = {hash: uint, key: K, value: V};
enum linear_map<K,V> { enum LinearMap<K,V> {
linear_map_({ LinearMap_({
hashfn: pure fn~(x: &K) -> uint, hashfn: pure fn~(x: &K) -> uint,
eqfn: pure fn~(x: &K, y: &K) -> bool, eqfn: pure fn~(x: &K, y: &K) -> bool,
resize_at: uint, resize_at: uint,
size: uint, size: uint,
buckets: ~[option<bucket<K,V>>]}) buckets: ~[option<Bucket<K,V>>]})
} }
// FIXME(#2979) -- with #2979 we could rewrite found_entry // FIXME(#2979) -- with #2979 we could rewrite found_entry
// to have type option<&bucket<K,V>> which would be nifty // to have type option<&bucket<K,V>> which would be nifty
enum search_result { enum SearchResult {
found_entry(uint), found_hole(uint), table_full FoundEntry(uint), FoundHole(uint), TableFull
} }
fn resize_at(capacity: uint) -> uint { fn resize_at(capacity: uint) -> uint {
@ -40,7 +40,7 @@ mod linear {
fn linear_map<K,V>( fn linear_map<K,V>(
+hashfn: pure fn~(x: &K) -> uint, +hashfn: pure fn~(x: &K) -> uint,
+eqfn: pure fn~(x: &K, y: &K) -> bool) -> linear_map<K,V> { +eqfn: pure fn~(x: &K, y: &K) -> bool) -> LinearMap<K,V> {
linear_map_with_capacity(hashfn, eqfn, 32) linear_map_with_capacity(hashfn, eqfn, 32)
} }
@ -48,9 +48,9 @@ mod linear {
fn linear_map_with_capacity<K,V>( fn linear_map_with_capacity<K,V>(
+hashfn: pure fn~(x: &K) -> uint, +hashfn: pure fn~(x: &K) -> uint,
+eqfn: pure fn~(x: &K, y: &K) -> bool, +eqfn: pure fn~(x: &K, y: &K) -> bool,
initial_capacity: uint) -> linear_map<K,V> { initial_capacity: uint) -> LinearMap<K,V> {
linear_map_({ LinearMap_({
hashfn: hashfn, hashfn: hashfn,
eqfn: eqfn, eqfn: eqfn,
resize_at: resize_at(initial_capacity), resize_at: resize_at(initial_capacity),
@ -64,7 +64,7 @@ mod linear {
unsafe::reinterpret_cast(p) unsafe::reinterpret_cast(p)
} }
priv impl<K, V> &const linear_map<K,V> { priv impl<K, V> &const LinearMap<K,V> {
#[inline(always)] #[inline(always)]
pure fn to_bucket(h: uint) -> uint { pure fn to_bucket(h: uint) -> uint {
// FIXME(#3041) borrow a more sophisticated technique here from // FIXME(#3041) borrow a more sophisticated technique here from
@ -101,8 +101,8 @@ mod linear {
#[inline(always)] #[inline(always)]
pure fn bucket_for_key( pure fn bucket_for_key(
buckets: &[option<bucket<K,V>>], buckets: &[option<Bucket<K,V>>],
k: &K) -> search_result { k: &K) -> SearchResult {
let hash = self.hashfn(k); let hash = self.hashfn(k);
self.bucket_for_key_with_hash(buckets, hash, k) self.bucket_for_key_with_hash(buckets, hash, k)
@ -110,23 +110,23 @@ mod linear {
#[inline(always)] #[inline(always)]
pure fn bucket_for_key_with_hash( pure fn bucket_for_key_with_hash(
buckets: &[option<bucket<K,V>>], buckets: &[option<Bucket<K,V>>],
hash: uint, hash: uint,
k: &K) -> search_result { k: &K) -> SearchResult {
let _ = for self.bucket_sequence(hash) |i| { let _ = for self.bucket_sequence(hash) |i| {
match buckets[i] { match buckets[i] {
some(bkt) => if bkt.hash == hash && self.eqfn(k, &bkt.key) { some(bkt) => if bkt.hash == hash && self.eqfn(k, &bkt.key) {
return found_entry(i); return FoundEntry(i);
}, },
none => return found_hole(i) none => return FoundHole(i)
} }
}; };
return table_full; return TableFull;
} }
} }
priv impl<K,V> &mut linear_map<K,V> { priv impl<K,V> &mut LinearMap<K,V> {
/// Expands the capacity of the array and re-inserts each /// Expands the capacity of the array and re-inserts each
/// of the existing buckets. /// of the existing buckets.
fn expand() { fn expand() {
@ -146,7 +146,7 @@ mod linear {
} }
} }
fn insert_bucket(+bucket: option<bucket<K,V>>) { fn insert_bucket(+bucket: option<Bucket<K,V>>) {
let {hash, key, value} <- option::unwrap(bucket); let {hash, key, value} <- option::unwrap(bucket);
let _ = self.insert_internal(hash, key, value); let _ = self.insert_internal(hash, key, value);
} }
@ -157,15 +157,15 @@ mod linear {
fn insert_internal(hash: uint, +k: K, +v: V) -> bool { fn insert_internal(hash: uint, +k: K, +v: V) -> bool {
match self.bucket_for_key_with_hash(self.buckets, hash, match self.bucket_for_key_with_hash(self.buckets, hash,
unsafe{borrow(k)}) { unsafe{borrow(k)}) {
table_full => {fail ~"Internal logic error";} TableFull => {fail ~"Internal logic error";}
found_hole(idx) => { FoundHole(idx) => {
debug!{"insert fresh (%?->%?) at idx %?, hash %?", debug!{"insert fresh (%?->%?) at idx %?, hash %?",
k, v, idx, hash}; k, v, idx, hash};
self.buckets[idx] = some({hash: hash, key: k, value: v}); self.buckets[idx] = some({hash: hash, key: k, value: v});
self.size += 1; self.size += 1;
return true; return true;
} }
found_entry(idx) => { FoundEntry(idx) => {
debug!{"insert overwrite (%?->%?) at idx %?, hash %?", debug!{"insert overwrite (%?->%?) at idx %?, hash %?",
k, v, idx, hash}; k, v, idx, hash};
self.buckets[idx] = some({hash: hash, key: k, value: v}); self.buckets[idx] = some({hash: hash, key: k, value: v});
@ -175,7 +175,7 @@ mod linear {
} }
} }
impl<K,V> &mut linear_map<K,V> { impl<K,V> &mut LinearMap<K,V> {
fn insert(+k: K, +v: V) -> bool { fn insert(+k: K, +v: V) -> bool {
if self.size >= self.resize_at { if self.size >= self.resize_at {
// n.b.: We could also do this after searching, so // n.b.: We could also do this after searching, so
@ -208,10 +208,10 @@ mod linear {
// http://www.maths.lse.ac.uk/Courses/MA407/del-hash.pdf // http://www.maths.lse.ac.uk/Courses/MA407/del-hash.pdf
let mut idx = match self.bucket_for_key(self.buckets, k) { let mut idx = match self.bucket_for_key(self.buckets, k) {
table_full | found_hole(_) => { TableFull | FoundHole(_) => {
return false; return false;
} }
found_entry(idx) => { FoundEntry(idx) => {
idx idx
} }
}; };
@ -230,13 +230,13 @@ mod linear {
} }
} }
priv impl<K,V> &linear_map<K,V> { priv impl<K,V> &LinearMap<K,V> {
fn search(hash: uint, op: fn(x: &option<bucket<K,V>>) -> bool) { fn search(hash: uint, op: fn(x: &option<Bucket<K,V>>) -> bool) {
let _ = self.bucket_sequence(hash, |i| op(&self.buckets[i])); let _ = self.bucket_sequence(hash, |i| op(&self.buckets[i]));
} }
} }
impl<K,V> &const linear_map<K,V> { impl<K,V> &const LinearMap<K,V> {
pure fn len() -> uint { pure fn len() -> uint {
self.size self.size
} }
@ -247,21 +247,21 @@ mod linear {
fn contains_key(k: &K) -> bool { fn contains_key(k: &K) -> bool {
match self.bucket_for_key(self.buckets, k) { match self.bucket_for_key(self.buckets, k) {
found_entry(_) => {true} FoundEntry(_) => {true}
table_full | found_hole(_) => {false} TableFull | FoundHole(_) => {false}
} }
} }
} }
impl<K,V: copy> &const linear_map<K,V> { impl<K,V: copy> &const LinearMap<K,V> {
fn find(k: &K) -> option<V> { fn find(k: &K) -> option<V> {
match self.bucket_for_key(self.buckets, k) { match self.bucket_for_key(self.buckets, k) {
found_entry(idx) => { FoundEntry(idx) => {
match check self.buckets[idx] { match check self.buckets[idx] {
some(bkt) => {some(copy bkt.value)} some(bkt) => {some(copy bkt.value)}
} }
} }
table_full | found_hole(_) => { TableFull | FoundHole(_) => {
none none
} }
} }
@ -277,7 +277,7 @@ mod linear {
} }
impl<K,V> &linear_map<K,V> { impl<K,V> &LinearMap<K,V> {
/* /*
FIXME --- #2979 must be fixed to typecheck this FIXME --- #2979 must be fixed to typecheck this
fn find_ptr(k: K) -> option<&V> { fn find_ptr(k: K) -> option<&V> {
@ -306,17 +306,17 @@ mod linear {
} }
} }
impl<K: copy, V: copy> &linear_map<K,V> { impl<K: copy, V: copy> &LinearMap<K,V> {
fn each(blk: fn(+K,+V) -> bool) { fn each(blk: fn(+K,+V) -> bool) {
self.each_ref(|k,v| blk(copy *k, copy *v)); self.each_ref(|k,v| blk(copy *k, copy *v));
} }
} }
impl<K: copy, V> &linear_map<K,V> { impl<K: copy, V> &LinearMap<K,V> {
fn each_key(blk: fn(+K) -> bool) { fn each_key(blk: fn(+K) -> bool) {
self.each_key_ref(|k| blk(copy *k)); self.each_key_ref(|k| blk(copy *k));
} }
} }
impl<K, V: copy> &linear_map<K,V> { impl<K, V: copy> &LinearMap<K,V> {
fn each_value(blk: fn(+V) -> bool) { fn each_value(blk: fn(+V) -> bool) {
self.each_value_ref(|v| blk(copy *v)); self.each_value_ref(|v| blk(copy *v));
} }
@ -326,12 +326,12 @@ mod linear {
#[test] #[test]
mod test { mod test {
import linear::linear_map; import linear::{LinearMap, linear_map};
pure fn uint_hash(x: &uint) -> uint { *x } pure fn uint_hash(x: &uint) -> uint { *x }
pure fn uint_eq(x: &uint, y: &uint) -> bool { *x == *y } pure fn uint_eq(x: &uint, y: &uint) -> bool { *x == *y }
fn int_linear_map<V>() -> linear_map<uint,V> { fn int_linear_map<V>() -> LinearMap<uint,V> {
return linear_map(uint_hash, uint_eq); return linear_map(uint_hash, uint_eq);
} }

View File

@ -108,8 +108,8 @@ export
unsafe, unsafe,
extensions, extensions,
str_slice, StrSlice,
unique_str; UniqueStr;
#[abi = "cdecl"] #[abi = "cdecl"]
extern mod rustrt { extern mod rustrt {
@ -1877,7 +1877,7 @@ mod unsafe {
/// Sets the length of the string and adds the null terminator /// Sets the length of the string and adds the null terminator
unsafe fn set_len(&v: ~str, new_len: uint) { unsafe fn set_len(&v: ~str, new_len: uint) {
let repr: *vec::unsafe::vec_repr = ::unsafe::reinterpret_cast(v); let repr: *vec::unsafe::VecRepr = ::unsafe::reinterpret_cast(v);
(*repr).fill = new_len + 1u; (*repr).fill = new_len + 1u;
let null = ptr::mut_offset(ptr::mut_addr_of((*repr).data), new_len); let null = ptr::mut_offset(ptr::mut_addr_of((*repr).data), new_len);
*null = 0u8; *null = 0u8;
@ -1895,14 +1895,14 @@ mod unsafe {
} }
trait unique_str { trait UniqueStr {
fn trim() -> self; fn trim() -> self;
fn trim_left() -> self; fn trim_left() -> self;
fn trim_right() -> self; fn trim_right() -> self;
} }
/// Extension methods for strings /// Extension methods for strings
impl ~str: unique_str { impl ~str: UniqueStr {
/// Returns a string with leading and trailing whitespace removed /// Returns a string with leading and trailing whitespace removed
#[inline] #[inline]
fn trim() -> ~str { trim(self) } fn trim() -> ~str { trim(self) }
@ -1922,7 +1922,7 @@ impl ~str: add<&str,~str> {
} }
} }
trait str_slice { trait StrSlice {
fn all(it: fn(char) -> bool) -> bool; fn all(it: fn(char) -> bool) -> bool;
fn any(it: fn(char) -> bool) -> bool; fn any(it: fn(char) -> bool) -> bool;
fn contains(needle: &a/str) -> bool; fn contains(needle: &a/str) -> bool;
@ -1951,7 +1951,7 @@ trait str_slice {
} }
/// Extension methods for strings /// Extension methods for strings
impl &str: str_slice { impl &str: StrSlice {
/** /**
* Return true if a predicate matches all characters or if the string * Return true if a predicate matches all characters or if the string
* contains no characters * contains no characters

View File

@ -693,7 +693,7 @@ type task_id = int;
type rust_task = libc::c_void; type rust_task = libc::c_void;
type rust_closure = libc::c_void; type rust_closure = libc::c_void;
type taskset = send_map::linear::linear_map<*rust_task,()>; type taskset = send_map::linear::LinearMap<*rust_task,()>;
fn new_taskset() -> taskset { fn new_taskset() -> taskset {
pure fn task_hash(t: &*rust_task) -> uint { pure fn task_hash(t: &*rust_task) -> uint {
@ -1271,7 +1271,7 @@ impl<T: owned> @T: local_data { }
// heavily in future, this could be made more efficient with a proper map. // heavily in future, this could be made more efficient with a proper map.
type task_local_element = (*libc::c_void, *libc::c_void, local_data); type task_local_element = (*libc::c_void, *libc::c_void, local_data);
// Has to be a pointer at outermost layer; the foreign call returns void *. // Has to be a pointer at outermost layer; the foreign call returns void *.
type task_local_map = @dvec::dvec<option<task_local_element>>; type task_local_map = @dvec::DVec<option<task_local_element>>;
extern fn cleanup_task_local_map(map_ptr: *libc::c_void) unsafe { extern fn cleanup_task_local_map(map_ptr: *libc::c_void) unsafe {
assert !map_ptr.is_null(); assert !map_ptr.is_null();

View File

@ -80,7 +80,7 @@ impl T: num::Num {
static pure fn from_int(n: int) -> T { return n as T; } static pure fn from_int(n: int) -> T { return n as T; }
} }
impl T: iter::times { impl T: iter::Times {
#[inline(always)] #[inline(always)]
#[doc = "A convenience form for basic iteration. Given a variable `x` \ #[doc = "A convenience form for basic iteration. Given a variable `x` \
of any numeric type, the expression `for x.times { /* anything */ }` \ of any numeric type, the expression `for x.times { /* anything */ }` \
@ -96,7 +96,7 @@ impl T: iter::times {
} }
} }
impl T: iter::timesi { impl T: iter::TimesIx {
#[inline(always)] #[inline(always)]
/// Like `times`, but with an index, `eachi`-style. /// Like `times`, but with an index, `eachi`-style.
fn timesi(it: fn(uint) -> bool) { fn timesi(it: fn(uint) -> bool) {
@ -295,7 +295,7 @@ fn to_str_radix17() {
#[test] #[test]
fn test_times() { fn test_times() {
import iter::times; import iter::Times;
let ten = 10 as T; let ten = 10 as T;
let mut accum = 0; let mut accum = 0;
for ten.times { accum += 1; } for ten.times { accum += 1; }

View File

@ -86,21 +86,21 @@ export as_const_buf;
export unsafe; export unsafe;
export u8; export u8;
export extensions; export extensions;
export const_vector; export ConstVector;
export copyable_vector; export CopyableVector;
export immutable_vector; export ImmutableVector;
export immutable_copyable_vector; export ImmutableCopyableVector;
export iter_trait_extensions; export IterTraitExtensions;
export vec_concat; export vec_concat;
#[abi = "cdecl"] #[abi = "cdecl"]
extern mod rustrt { extern mod rustrt {
fn vec_reserve_shared(++t: *sys::TypeDesc, fn vec_reserve_shared(++t: *sys::TypeDesc,
++v: **unsafe::vec_repr, ++v: **unsafe::VecRepr,
++n: libc::size_t); ++n: libc::size_t);
fn vec_from_buf_shared(++t: *sys::TypeDesc, fn vec_from_buf_shared(++t: *sys::TypeDesc,
++ptr: *(), ++ptr: *(),
++count: libc::size_t) -> *unsafe::vec_repr; ++count: libc::size_t) -> *unsafe::VecRepr;
} }
#[abi = "rust-intrinsic"] #[abi = "rust-intrinsic"]
@ -109,7 +109,7 @@ extern mod rusti {
} }
/// A function used to initialize the elements of a vector /// A function used to initialize the elements of a vector
type init_op/&<T> = fn(uint) -> T; type InitOp/&<T> = fn(uint) -> T;
/// Returns true if a vector contains no elements /// Returns true if a vector contains no elements
pure fn is_empty<T>(v: &[const T]) -> bool { pure fn is_empty<T>(v: &[const T]) -> bool {
@ -140,7 +140,7 @@ pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
fn reserve<T>(&v: ~[const T], n: uint) { fn reserve<T>(&v: ~[const T], n: uint) {
// Only make the (slow) call into the runtime if we have to // Only make the (slow) call into the runtime if we have to
if capacity(v) < n { if capacity(v) < n {
let ptr = ptr::addr_of(v) as **unsafe::vec_repr; let ptr = ptr::addr_of(v) as **unsafe::VecRepr;
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(), rustrt::vec_reserve_shared(sys::get_type_desc::<T>(),
ptr, n as size_t); ptr, n as size_t);
} }
@ -169,7 +169,7 @@ fn reserve_at_least<T>(&v: ~[const T], n: uint) {
#[inline(always)] #[inline(always)]
pure fn capacity<T>(&&v: ~[const T]) -> uint { pure fn capacity<T>(&&v: ~[const T]) -> uint {
unsafe { unsafe {
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
(**repr).alloc / sys::size_of::<T>() (**repr).alloc / sys::size_of::<T>()
} }
} }
@ -186,7 +186,7 @@ pure fn len<T>(&&v: &[const T]) -> uint {
* Creates an immutable vector of size `n_elts` and initializes the elements * Creates an immutable vector of size `n_elts` and initializes the elements
* to the value returned by the function `op`. * to the value returned by the function `op`.
*/ */
pure fn from_fn<T>(n_elts: uint, op: init_op<T>) -> ~[T] { pure fn from_fn<T>(n_elts: uint, op: InitOp<T>) -> ~[T] {
let mut v = ~[]; let mut v = ~[];
unchecked{reserve(v, n_elts);} unchecked{reserve(v, n_elts);}
let mut i: uint = 0u; let mut i: uint = 0u;
@ -523,7 +523,7 @@ fn pop<T>(&v: ~[const T]) -> T {
#[inline(always)] #[inline(always)]
fn push<T>(&v: ~[const T], +initval: T) { fn push<T>(&v: ~[const T], +initval: T) {
unsafe { unsafe {
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
let fill = (**repr).fill; let fill = (**repr).fill;
if (**repr).alloc > fill { if (**repr).alloc > fill {
push_fast(v, initval); push_fast(v, initval);
@ -537,7 +537,7 @@ fn push<T>(&v: ~[const T], +initval: T) {
// This doesn't bother to make sure we have space. // This doesn't bother to make sure we have space.
#[inline(always)] // really pretty please #[inline(always)] // really pretty please
unsafe fn push_fast<T>(&v: ~[const T], +initval: T) { unsafe fn push_fast<T>(&v: ~[const T], +initval: T) {
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
let fill = (**repr).fill; let fill = (**repr).fill;
(**repr).fill += sys::size_of::<T>(); (**repr).fill += sys::size_of::<T>();
let p = ptr::addr_of((**repr).data); let p = ptr::addr_of((**repr).data);
@ -640,7 +640,7 @@ fn grow<T: copy>(&v: ~[const T], n: uint, initval: T) {
* * init_op - A function to call to retreive each appended element's * * init_op - A function to call to retreive each appended element's
* value * value
*/ */
fn grow_fn<T>(&v: ~[const T], n: uint, op: init_op<T>) { fn grow_fn<T>(&v: ~[const T], n: uint, op: InitOp<T>) {
reserve_at_least(v, len(v) + n); reserve_at_least(v, len(v) + n);
let mut i: uint = 0u; let mut i: uint = 0u;
while i < n { push(v, op(i)); i += 1u; } while i < n { push(v, op(i)); i += 1u; }
@ -1304,14 +1304,14 @@ impl<T: copy> ~[mut T]: add<&[const T],~[mut T]> {
} }
} }
trait const_vector { trait ConstVector {
pure fn is_empty() -> bool; pure fn is_empty() -> bool;
pure fn is_not_empty() -> bool; pure fn is_not_empty() -> bool;
pure fn len() -> uint; pure fn len() -> uint;
} }
/// Extension methods for vectors /// Extension methods for vectors
impl<T> &[const T]: const_vector { impl<T> &[const T]: ConstVector {
/// Returns true if a vector contains no elements /// Returns true if a vector contains no elements
#[inline] #[inline]
pure fn is_empty() -> bool { is_empty(self) } pure fn is_empty() -> bool { is_empty(self) }
@ -1323,7 +1323,7 @@ impl<T> &[const T]: const_vector {
pure fn len() -> uint { len(self) } pure fn len() -> uint { len(self) }
} }
trait copyable_vector<T> { trait CopyableVector<T> {
pure fn head() -> T; pure fn head() -> T;
pure fn init() -> ~[T]; pure fn init() -> ~[T];
pure fn last() -> T; pure fn last() -> T;
@ -1332,7 +1332,7 @@ trait copyable_vector<T> {
} }
/// Extension methods for vectors /// Extension methods for vectors
impl<T: copy> &[const T]: copyable_vector<T> { impl<T: copy> &[const T]: CopyableVector<T> {
/// Returns the first element of a vector /// Returns the first element of a vector
#[inline] #[inline]
pure fn head() -> T { head(self) } pure fn head() -> T { head(self) }
@ -1350,7 +1350,7 @@ impl<T: copy> &[const T]: copyable_vector<T> {
pure fn tail() -> ~[T] { tail(self) } pure fn tail() -> ~[T] { tail(self) }
} }
trait immutable_vector<T> { trait ImmutableVector<T> {
pure fn foldr<U: copy>(z: U, p: fn(T, U) -> U) -> U; pure fn foldr<U: copy>(z: U, p: fn(T, U) -> U) -> U;
pure fn iter(f: fn(T)); pure fn iter(f: fn(T));
pure fn iteri(f: fn(uint, T)); pure fn iteri(f: fn(uint, T));
@ -1369,7 +1369,7 @@ trait immutable_vector<T> {
} }
/// Extension methods for vectors /// Extension methods for vectors
impl<T> &[T]: immutable_vector<T> { impl<T> &[T]: ImmutableVector<T> {
/// Reduce a vector from right to left /// Reduce a vector from right to left
#[inline] #[inline]
pure fn foldr<U: copy>(z: U, p: fn(T, U) -> U) -> U { foldr(self, z, p) } pure fn foldr<U: copy>(z: U, p: fn(T, U) -> U) -> U { foldr(self, z, p) }
@ -1477,14 +1477,14 @@ impl<T> &[T]: immutable_vector<T> {
} }
} }
trait immutable_copyable_vector<T> { trait ImmutableCopyableVector<T> {
pure fn filter(f: fn(T) -> bool) -> ~[T]; pure fn filter(f: fn(T) -> bool) -> ~[T];
pure fn find(f: fn(T) -> bool) -> option<T>; pure fn find(f: fn(T) -> bool) -> option<T>;
pure fn rfind(f: fn(T) -> bool) -> option<T>; pure fn rfind(f: fn(T) -> bool) -> option<T>;
} }
/// Extension methods for vectors /// Extension methods for vectors
impl<T: copy> &[T]: immutable_copyable_vector<T> { impl<T: copy> &[T]: ImmutableCopyableVector<T> {
/** /**
* Construct a new vector from the elements of a vector for which some * Construct a new vector from the elements of a vector for which some
* predicate holds. * predicate holds.
@ -1518,14 +1518,14 @@ impl<T: copy> &[T]: immutable_copyable_vector<T> {
mod unsafe { mod unsafe {
// FIXME: This should have crate visibility (#1893 blocks that) // FIXME: This should have crate visibility (#1893 blocks that)
/// The internal representation of a vector /// The internal representation of a vector
type vec_repr = { type VecRepr = {
box_header: (uint, uint, uint, uint), box_header: (uint, uint, uint, uint),
mut fill: uint, mut fill: uint,
mut alloc: uint, mut alloc: uint,
data: u8 data: u8
}; };
type slice_repr = { type SliceRepr = {
mut data: *u8, mut data: *u8,
mut len: uint mut len: uint
}; };
@ -1555,7 +1555,7 @@ mod unsafe {
*/ */
#[inline(always)] #[inline(always)]
unsafe fn set_len<T>(&&v: ~[const T], new_len: uint) { unsafe fn set_len<T>(&&v: ~[const T], new_len: uint) {
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); let repr: **VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
(**repr).fill = new_len * sys::size_of::<T>(); (**repr).fill = new_len * sys::size_of::<T>();
} }
@ -1570,14 +1570,14 @@ mod unsafe {
*/ */
#[inline(always)] #[inline(always)]
unsafe fn to_ptr<T>(v: ~[const T]) -> *T { unsafe fn to_ptr<T>(v: ~[const T]) -> *T {
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); let repr: **VecRepr = ::unsafe::reinterpret_cast(addr_of(v));
return ::unsafe::reinterpret_cast(addr_of((**repr).data)); return ::unsafe::reinterpret_cast(addr_of((**repr).data));
} }
#[inline(always)] #[inline(always)]
unsafe fn to_ptr_slice<T>(v: &[const T]) -> *T { unsafe fn to_ptr_slice<T>(v: &[const T]) -> *T {
let repr: **slice_repr = ::unsafe::reinterpret_cast(addr_of(v)); let repr: **SliceRepr = ::unsafe::reinterpret_cast(addr_of(v));
return ::unsafe::reinterpret_cast(addr_of((**repr).data)); return ::unsafe::reinterpret_cast(addr_of((**repr).data));
} }
@ -1729,12 +1729,12 @@ mod u8 {
// This cannot be used with iter-trait.rs because of the region pointer // This cannot be used with iter-trait.rs because of the region pointer
// required in the slice. // required in the slice.
impl<A> &[A]: iter::base_iter<A> { impl<A> &[A]: iter::BaseIter<A> {
fn each(blk: fn(A) -> bool) { each(self, blk) } fn each(blk: fn(A) -> bool) { each(self, blk) }
fn size_hint() -> option<uint> { some(len(self)) } fn size_hint() -> option<uint> { some(len(self)) }
} }
impl<A> &[A]: iter::extended_iter<A> { impl<A> &[A]: iter::ExtendedIter<A> {
fn eachi(blk: fn(uint, A) -> bool) { iter::eachi(self, blk) } fn eachi(blk: fn(uint, A) -> bool) { iter::eachi(self, blk) }
fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) } fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) }
fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) } fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) }
@ -1746,7 +1746,7 @@ impl<A> &[A]: iter::extended_iter<A> {
fn position(f: fn(A) -> bool) -> option<uint> { iter::position(self, f) } fn position(f: fn(A) -> bool) -> option<uint> { iter::position(self, f) }
} }
trait iter_trait_extensions<A> { trait IterTraitExtensions<A> {
fn filter_to_vec(pred: fn(A) -> bool) -> ~[A]; fn filter_to_vec(pred: fn(A) -> bool) -> ~[A];
fn map_to_vec<B>(op: fn(A) -> B) -> ~[B]; fn map_to_vec<B>(op: fn(A) -> B) -> ~[B];
fn to_vec() -> ~[A]; fn to_vec() -> ~[A];
@ -1754,7 +1754,7 @@ trait iter_trait_extensions<A> {
fn max() -> A; fn max() -> A;
} }
impl<A: copy> &[A]: iter_trait_extensions<A> { impl<A: copy> &[A]: IterTraitExtensions<A> {
fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] { fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred) iter::filter_to_vec(self, pred)
} }

View File

@ -1,7 +1,7 @@
//! A deque. Untested as of yet. Likely buggy //! A deque. Untested as of yet. Likely buggy
import option::{some, none}; import option::{some, none};
import dvec::dvec; import dvec::{DVec, dvec};
trait t<T> { trait t<T> {
fn size() -> uint; fn size() -> uint;
@ -40,14 +40,14 @@ fn create<T: copy>() -> t<T> {
return rv; return rv;
} }
fn get<T: copy>(elts: dvec<cell<T>>, i: uint) -> T { fn get<T: copy>(elts: DVec<cell<T>>, i: uint) -> T {
match elts.get_elt(i) { some(t) => t, _ => fail } match elts.get_elt(i) { some(t) => t, _ => fail }
} }
type repr<T> = {mut nelts: uint, type repr<T> = {mut nelts: uint,
mut lo: uint, mut lo: uint,
mut hi: uint, mut hi: uint,
elts: dvec<cell<T>>}; elts: DVec<cell<T>>};
impl <T: copy> repr<T>: t<T> { impl <T: copy> repr<T>: t<T> {
fn size() -> uint { return self.nelts; } fn size() -> uint { return self.nelts; }

View File

@ -3,7 +3,7 @@
import map; import map;
import map::{hashmap, str_hash}; import map::{hashmap, str_hash};
import io::Reader; import io::Reader;
import dvec::dvec; import dvec::{DVec, dvec};
export url, userinfo, query; export url, userinfo, query;
export from_str, to_str; export from_str, to_str;
@ -176,7 +176,7 @@ fn encode_plus(s: ~str) -> ~str {
/** /**
* Encode a hashmap to the 'application/x-www-form-urlencoded' media type. * Encode a hashmap to the 'application/x-www-form-urlencoded' media type.
*/ */
fn encode_form_urlencoded(m: hashmap<~str, @dvec<@~str>>) -> ~str { fn encode_form_urlencoded(m: hashmap<~str, @DVec<@~str>>) -> ~str {
let mut out = ~""; let mut out = ~"";
let mut first = true; let mut first = true;
@ -203,7 +203,7 @@ fn encode_form_urlencoded(m: hashmap<~str, @dvec<@~str>>) -> ~str {
* type into a hashmap. * type into a hashmap.
*/ */
fn decode_form_urlencoded(s: ~[u8]) -> fn decode_form_urlencoded(s: ~[u8]) ->
map::hashmap<~str, @dvec::dvec<@~str>> { map::hashmap<~str, @dvec::DVec<@~str>> {
do io::with_bytes_reader(s) |rdr| { do io::with_bytes_reader(s) |rdr| {
let m = str_hash(); let m = str_hash();
let mut key = ~""; let mut key = ~"";

View File

@ -4,12 +4,12 @@
*/ */
import core::option; import core::option;
import core::option::{some, none}; import core::option::{some, none};
import dvec::dvec; import dvec::{DVec, dvec};
import map::map; import map::map;
// FIXME (#2347): Should not be @; there's a bug somewhere in rustc that // FIXME (#2347): Should not be @; there's a bug somewhere in rustc that
// requires this to be. // requires this to be.
type smallintmap_<T: copy> = {v: dvec<option<T>>}; type smallintmap_<T: copy> = {v: DVec<option<T>>};
enum smallintmap<T:copy> { enum smallintmap<T:copy> {
smallintmap_(@smallintmap_<T>) smallintmap_(@smallintmap_<T>)

View File

@ -5,7 +5,7 @@
// simplest interface possible for representing and running tests // simplest interface possible for representing and running tests
// while providing a base that other test frameworks may build off of. // while providing a base that other test frameworks may build off of.
import either::either; import either::Either;
import result::{ok, err}; import result::{ok, err};
import io::WriterUtil; import io::WriterUtil;
import libc::size_t; import libc::size_t;
@ -53,8 +53,8 @@ type test_desc = {
fn test_main(args: ~[~str], tests: ~[test_desc]) { fn test_main(args: ~[~str], tests: ~[test_desc]) {
let opts = let opts =
match parse_opts(args) { match parse_opts(args) {
either::left(o) => o, either::Left(o) => o,
either::right(m) => fail m either::Right(m) => fail m
}; };
if !run_tests_console(opts, tests) { fail ~"Some tests failed"; } if !run_tests_console(opts, tests) { fail ~"Some tests failed"; }
} }
@ -62,7 +62,7 @@ fn test_main(args: ~[~str], tests: ~[test_desc]) {
type test_opts = {filter: option<~str>, run_ignored: bool, type test_opts = {filter: option<~str>, run_ignored: bool,
logfile: option<~str>}; logfile: option<~str>};
type opt_res = either<test_opts, ~str>; type opt_res = Either<test_opts, ~str>;
// Parses command line arguments into test options // Parses command line arguments into test options
fn parse_opts(args: ~[~str]) -> opt_res { fn parse_opts(args: ~[~str]) -> opt_res {
@ -71,7 +71,7 @@ fn parse_opts(args: ~[~str]) -> opt_res {
let matches = let matches =
match getopts::getopts(args_, opts) { match getopts::getopts(args_, opts) {
ok(m) => m, ok(m) => m,
err(f) => return either::right(getopts::fail_str(f)) err(f) => return either::Right(getopts::fail_str(f))
}; };
let filter = let filter =
@ -85,7 +85,7 @@ fn parse_opts(args: ~[~str]) -> opt_res {
let test_opts = {filter: filter, run_ignored: run_ignored, let test_opts = {filter: filter, run_ignored: run_ignored,
logfile: logfile}; logfile: logfile};
return either::left(test_opts); return either::Left(test_opts);
} }
enum test_result { tr_ok, tr_failed, tr_ignored, } enum test_result { tr_ok, tr_failed, tr_ignored, }
@ -479,7 +479,7 @@ mod tests {
fn first_free_arg_should_be_a_filter() { fn first_free_arg_should_be_a_filter() {
let args = ~[~"progname", ~"filter"]; let args = ~[~"progname", ~"filter"];
let opts = match parse_opts(args) { let opts = match parse_opts(args) {
either::left(o) => o, either::Left(o) => o,
_ => fail ~"Malformed arg in first_free_arg_should_be_a_filter" _ => fail ~"Malformed arg in first_free_arg_should_be_a_filter"
}; };
assert ~"filter" == option::get(opts.filter); assert ~"filter" == option::get(opts.filter);
@ -489,7 +489,7 @@ mod tests {
fn parse_ignored_flag() { fn parse_ignored_flag() {
let args = ~[~"progname", ~"filter", ~"--ignored"]; let args = ~[~"progname", ~"filter", ~"--ignored"];
let opts = match parse_opts(args) { let opts = match parse_opts(args) {
either::left(o) => o, either::Left(o) => o,
_ => fail ~"Malformed arg in parse_ignored_flag" _ => fail ~"Malformed arg in parse_ignored_flag"
}; };
assert (opts.run_ignored); assert (opts.run_ignored);

View File

@ -9,7 +9,7 @@ import iotask::{iotask, spawn_iotask};
import priv::{chan_from_global_ptr, weaken_task}; import priv::{chan_from_global_ptr, weaken_task};
import comm::{port, chan, select2, listen}; import comm::{port, chan, select2, listen};
import task::task_builder; import task::task_builder;
import either::{left, right}; import either::{Left, Right};
extern mod rustrt { extern mod rustrt {
fn rust_uv_get_kernel_global_chan_ptr() -> *libc::uintptr_t; fn rust_uv_get_kernel_global_chan_ptr() -> *libc::uintptr_t;
@ -58,14 +58,14 @@ fn get_monitor_task_gl() -> iotask unsafe {
loop { loop {
debug!{"in outer_loop..."}; debug!{"in outer_loop..."};
match select2(weak_exit_po, msg_po) { match select2(weak_exit_po, msg_po) {
left(weak_exit) => { Left(weak_exit) => {
// all normal tasks have ended, tell the // all normal tasks have ended, tell the
// libuv loop to tear_down, then exit // libuv loop to tear_down, then exit
debug!{"weak_exit_po recv'd msg: %?", weak_exit}; debug!{"weak_exit_po recv'd msg: %?", weak_exit};
iotask::exit(hl_loop); iotask::exit(hl_loop);
break; break;
} }
right(fetch_ch) => { Right(fetch_ch) => {
debug!{"hl_loop req recv'd: %?", fetch_ch}; debug!{"hl_loop req recv'd: %?", fetch_ch};
fetch_ch.send(hl_loop); fetch_ch.send(hl_loop);
} }

View File

@ -205,8 +205,8 @@ fn map_item(i: @item, cx: ctx, v: vt) {
} }
item_foreign_mod(nm) => { item_foreign_mod(nm) => {
let abi = match attr::foreign_abi(i.attrs) { let abi = match attr::foreign_abi(i.attrs) {
either::left(msg) => cx.diag.span_fatal(i.span, msg), either::Left(msg) => cx.diag.span_fatal(i.span, msg),
either::right(abi) => abi either::Right(abi) => abi
}; };
for nm.items.each |nitem| { for nm.items.each |nitem| {
cx.map.insert(nitem.id, cx.map.insert(nitem.id,

View File

@ -2,7 +2,7 @@
import std::map; import std::map;
import std::map::hashmap; import std::map::hashmap;
import either::either; import either::Either;
import diagnostic::span_handler; import diagnostic::span_handler;
import ast_util::{spanned, dummy_spanned}; import ast_util::{spanned, dummy_spanned};
import parse::comments::{doc_comment_style, strip_doc_comment_decoration}; import parse::comments::{doc_comment_style, strip_doc_comment_decoration};
@ -330,22 +330,22 @@ fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] {
} }
} }
fn foreign_abi(attrs: ~[ast::attribute]) -> either<~str, ast::foreign_abi> { fn foreign_abi(attrs: ~[ast::attribute]) -> Either<~str, ast::foreign_abi> {
return match attr::first_attr_value_str_by_name(attrs, ~"abi") { return match attr::first_attr_value_str_by_name(attrs, ~"abi") {
option::none => { option::none => {
either::right(ast::foreign_abi_cdecl) either::Right(ast::foreign_abi_cdecl)
} }
option::some(@~"rust-intrinsic") => { option::some(@~"rust-intrinsic") => {
either::right(ast::foreign_abi_rust_intrinsic) either::Right(ast::foreign_abi_rust_intrinsic)
} }
option::some(@~"cdecl") => { option::some(@~"cdecl") => {
either::right(ast::foreign_abi_cdecl) either::Right(ast::foreign_abi_cdecl)
} }
option::some(@~"stdcall") => { option::some(@~"stdcall") => {
either::right(ast::foreign_abi_stdcall) either::Right(ast::foreign_abi_stdcall)
} }
option::some(t) => { option::some(t) => {
either::left(~"unsupported abi: " + *t) either::Left(~"unsupported abi: " + *t)
} }
}; };
} }

View File

@ -1,4 +1,4 @@
import dvec::dvec; import dvec::{DVec, dvec};
export filename; export filename;
export filemap; export filemap;
@ -48,7 +48,7 @@ type filemap =
@{name: filename, substr: file_substr, src: @~str, @{name: filename, substr: file_substr, src: @~str,
start_pos: file_pos, mut lines: ~[file_pos]}; start_pos: file_pos, mut lines: ~[file_pos]};
type codemap = @{files: dvec<filemap>}; type codemap = @{files: DVec<filemap>};
type loc = {file: filemap, line: uint, col: uint}; type loc = {file: filemap, line: uint, col: uint};

View File

@ -1,5 +1,5 @@
import to_str::ToStr; import to_str::ToStr;
import dvec::dvec; import dvec::{DVec, dvec};
import ast::{ident}; import ast::{ident};
@ -62,7 +62,7 @@ enum state {
span: span, span: span,
dir: direction, dir: direction,
ty_params: ~[ast::ty_param], ty_params: ~[ast::ty_param],
messages: dvec<message>, messages: DVec<message>,
proto: protocol, proto: protocol,
}), }),
} }
@ -112,7 +112,7 @@ fn protocol(name: ident, +span: span) -> protocol {
class protocol_ { class protocol_ {
let name: ident; let name: ident;
let span: span; let span: span;
let states: dvec<state>; let states: DVec<state>;
let mut bounded: option<bool>; let mut bounded: option<bool>;

View File

@ -2,7 +2,7 @@ import ast::{crate, expr_, mac_invoc,
mac_aq, mac_var}; mac_aq, mac_var};
import parse::parser; import parse::parser;
import parse::parser::parse_from_source_str; import parse::parser::parse_from_source_str;
import dvec::dvec; import dvec::{DVec, dvec};
import fold::*; import fold::*;
import visit::*; import visit::*;
@ -20,7 +20,7 @@ struct gather_item {
constr: ~str; constr: ~str;
} }
type aq_ctxt = @{lo: uint, gather: dvec<gather_item>}; type aq_ctxt = @{lo: uint, gather: DVec<gather_item>};
enum fragment { enum fragment {
from_expr(@ast::expr), from_expr(@ast::expr),
from_ty(@ast::ty) from_ty(@ast::ty)

View File

@ -1,6 +1,6 @@
import codemap::span; import codemap::span;
import std::map::{hashmap, str_hash, box_str_hash}; import std::map::{hashmap, str_hash, box_str_hash};
import dvec::dvec; import dvec::{DVec, dvec};
import base::*; import base::*;
@ -124,7 +124,7 @@ fn compose_sels(s1: selector, s2: selector) -> selector {
type binders = type binders =
{real_binders: hashmap<ident, selector>, {real_binders: hashmap<ident, selector>,
literal_ast_matchers: dvec<selector>}; literal_ast_matchers: DVec<selector>};
type bindings = hashmap<ident, arb_depth<matchable>>; type bindings = hashmap<ident, arb_depth<matchable>>;
fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { } fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { }

View File

@ -7,7 +7,7 @@ import parse::parser::{parser,SOURCE_FILE};
//import parse::common::parser_common; //import parse::common::parser_common;
import parse::common::*; //resolve bug? import parse::common::*; //resolve bug?
import parse::parse_sess; import parse::parse_sess;
import dvec::dvec; import dvec::{DVec, dvec};
import ast::{matcher, match_tok, match_seq, match_nonterminal, ident}; import ast::{matcher, match_tok, match_seq, match_nonterminal, ident};
import ast_util::mk_sp; import ast_util::mk_sp;
import std::map::{hashmap, box_str_hash}; import std::map::{hashmap, box_str_hash};
@ -42,7 +42,7 @@ type matcher_pos = ~{
sep: option<token>, sep: option<token>,
mut idx: uint, mut idx: uint,
mut up: matcher_pos_up, // mutable for swapping only mut up: matcher_pos_up, // mutable for swapping only
matches: ~[dvec<@named_match>], matches: ~[DVec<@named_match>],
match_lo: uint, match_hi: uint, match_lo: uint, match_hi: uint,
sp_lo: uint, sp_lo: uint,
}; };

View File

@ -1,4 +1,4 @@
import either::{either, left, right}; import either::{Either, Left, Right};
import ast_util::spanned; import ast_util::spanned;
import common::*; //resolve bug? import common::*; //resolve bug?
@ -7,7 +7,7 @@ export parser_attr;
// A type to distingush between the parsing of item attributes or syntax // A type to distingush between the parsing of item attributes or syntax
// extensions, which both begin with token.POUND // extensions, which both begin with token.POUND
type attr_or_ext = option<either<~[ast::attribute], @ast::expr>>; type attr_or_ext = option<Either<~[ast::attribute], @ast::expr>>;
trait parser_attr { trait parser_attr {
fn parse_outer_attrs_or_ext(first_item_attrs: ~[ast::attribute]) fn parse_outer_attrs_or_ext(first_item_attrs: ~[ast::attribute])
@ -36,18 +36,18 @@ impl parser: parser_attr {
self.bump(); self.bump();
let first_attr = let first_attr =
self.parse_attribute_naked(ast::attr_outer, lo); self.parse_attribute_naked(ast::attr_outer, lo);
return some(left(vec::append(~[first_attr], return some(Left(vec::append(~[first_attr],
self.parse_outer_attributes()))); self.parse_outer_attributes())));
} else if !(self.look_ahead(1u) == token::LT } else if !(self.look_ahead(1u) == token::LT
|| self.look_ahead(1u) == token::LBRACKET || self.look_ahead(1u) == token::LBRACKET
|| self.look_ahead(1u) == token::POUND || self.look_ahead(1u) == token::POUND
|| expect_item_next) { || expect_item_next) {
self.bump(); self.bump();
return some(right(self.parse_syntax_ext_naked(lo))); return some(Right(self.parse_syntax_ext_naked(lo)));
} else { return none; } } else { return none; }
} }
token::DOC_COMMENT(_) => { token::DOC_COMMENT(_) => {
return some(left(self.parse_outer_attributes())); return some(Left(self.parse_outer_attributes()));
} }
_ => return none _ => return none
} }

View File

@ -340,40 +340,40 @@ fn scan_number(c: char, rdr: string_reader) -> token::token {
if c == 'u' || c == 'i' { if c == 'u' || c == 'i' {
let signed = c == 'i'; let signed = c == 'i';
let mut tp = { let mut tp = {
if signed { either::left(ast::ty_i) } if signed { either::Left(ast::ty_i) }
else { either::right(ast::ty_u) } else { either::Right(ast::ty_u) }
}; };
bump(rdr); bump(rdr);
c = rdr.curr; c = rdr.curr;
if c == '8' { if c == '8' {
bump(rdr); bump(rdr);
tp = if signed { either::left(ast::ty_i8) } tp = if signed { either::Left(ast::ty_i8) }
else { either::right(ast::ty_u8) }; else { either::Right(ast::ty_u8) };
} }
n = nextch(rdr); n = nextch(rdr);
if c == '1' && n == '6' { if c == '1' && n == '6' {
bump(rdr); bump(rdr);
bump(rdr); bump(rdr);
tp = if signed { either::left(ast::ty_i16) } tp = if signed { either::Left(ast::ty_i16) }
else { either::right(ast::ty_u16) }; else { either::Right(ast::ty_u16) };
} else if c == '3' && n == '2' { } else if c == '3' && n == '2' {
bump(rdr); bump(rdr);
bump(rdr); bump(rdr);
tp = if signed { either::left(ast::ty_i32) } tp = if signed { either::Left(ast::ty_i32) }
else { either::right(ast::ty_u32) }; else { either::Right(ast::ty_u32) };
} else if c == '6' && n == '4' { } else if c == '6' && n == '4' {
bump(rdr); bump(rdr);
bump(rdr); bump(rdr);
tp = if signed { either::left(ast::ty_i64) } tp = if signed { either::Left(ast::ty_i64) }
else { either::right(ast::ty_u64) }; else { either::Right(ast::ty_u64) };
} }
if str::len(num_str) == 0u { if str::len(num_str) == 0u {
rdr.fatal(~"no valid digits found for number"); rdr.fatal(~"no valid digits found for number");
} }
let parsed = option::get(u64::from_str_radix(num_str, base as u64)); let parsed = option::get(u64::from_str_radix(num_str, base as u64));
match tp { match tp {
either::left(t) => return token::LIT_INT(parsed as i64, t), either::Left(t) => return token::LIT_INT(parsed as i64, t),
either::right(t) => return token::LIT_UINT(parsed, t) either::Right(t) => return token::LIT_UINT(parsed, t)
} }
} }
let mut is_float = false; let mut is_float = false;

View File

@ -1,7 +1,7 @@
import print::pprust::expr_to_str; import print::pprust::expr_to_str;
import result::result; import result::result;
import either::{either, left, right}; import either::{Either, Left, Right};
import std::map::{hashmap, str_hash}; import std::map::{hashmap, str_hash};
import token::{can_begin_expr, is_ident, is_ident_or_path, is_plain_ident, import token::{can_begin_expr, is_ident, is_ident_or_path, is_plain_ident,
INTERPOLATED}; INTERPOLATED};
@ -102,7 +102,7 @@ enum class_contents { ctor_decl(fn_decl, ~[attribute], blk, codemap::span),
dtor_decl(blk, ~[attribute], codemap::span), dtor_decl(blk, ~[attribute], codemap::span),
members(~[@class_member]) } members(~[@class_member]) }
type arg_or_capture_item = either<arg, capture_item>; type arg_or_capture_item = Either<arg, capture_item>;
type item_info = (ident, item_, option<~[attribute]>); type item_info = (ident, item_, option<~[attribute]>);
enum item_or_view_item { enum item_or_view_item {
@ -557,9 +557,9 @@ class parser {
} }
if self.eat_keyword(~"move") { if self.eat_keyword(~"move") {
either::right(parse_capture_item(self, true)) either::Right(parse_capture_item(self, true))
} else if self.eat_keyword(~"copy") { } else if self.eat_keyword(~"copy") {
either::right(parse_capture_item(self, false)) either::Right(parse_capture_item(self, false))
} else { } else {
parse_arg_fn(self) parse_arg_fn(self)
} }
@ -570,7 +570,7 @@ class parser {
let i = self.parse_value_ident(); let i = self.parse_value_ident();
self.expect(token::COLON); self.expect(token::COLON);
let t = self.parse_ty(false); let t = self.parse_ty(false);
either::left({mode: m, ty: t, ident: i, id: self.get_id()}) either::Left({mode: m, ty: t, ident: i, id: self.get_id()})
} }
fn parse_arg_or_capture_item() -> arg_or_capture_item { fn parse_arg_or_capture_item() -> arg_or_capture_item {
@ -588,7 +588,7 @@ class parser {
node: ty_infer, node: ty_infer,
span: mk_sp(p.span.lo, p.span.hi)} span: mk_sp(p.span.lo, p.span.hi)}
}; };
either::left({mode: m, ty: t, ident: i, id: p.get_id()}) either::Left({mode: m, ty: t, ident: i, id: p.get_id()})
} }
} }
@ -2051,8 +2051,8 @@ class parser {
let mut item_attrs; let mut item_attrs;
match self.parse_outer_attrs_or_ext(first_item_attrs) { match self.parse_outer_attrs_or_ext(first_item_attrs) {
none => item_attrs = ~[], none => item_attrs = ~[],
some(left(attrs)) => item_attrs = attrs, some(Left(attrs)) => item_attrs = attrs,
some(right(ext)) => { some(Right(ext)) => {
return @spanned(lo, ext.span.hi, return @spanned(lo, ext.span.hi,
stmt_expr(ext, self.get_id())); stmt_expr(ext, self.get_id()));
} }

View File

@ -1,5 +1,5 @@
import io::WriterUtil; import io::WriterUtil;
import dvec::dvec; import dvec::{DVec, dvec};
/* /*
* This pretty-printer is a direct reimplementation of Philip Karlton's * This pretty-printer is a direct reimplementation of Philip Karlton's
@ -222,7 +222,7 @@ type printer_ = {
mut top: uint, // index of top of scan_stack mut top: uint, // index of top of scan_stack
mut bottom: uint, // index of bottom of scan_stack mut bottom: uint, // index of bottom of scan_stack
// stack of blocks-in-progress being flushed by print // stack of blocks-in-progress being flushed by print
print_stack: dvec<print_stack_elt>, print_stack: DVec<print_stack_elt>,
// buffered indentation to avoid writing trailing whitespace // buffered indentation to avoid writing trailing whitespace
mut pending_indentation: int, mut pending_indentation: int,
mut token_tree_last_was_ident: bool mut token_tree_last_was_ident: bool

View File

@ -7,7 +7,7 @@ import pp::{break_offset, word, printer,
import diagnostic; import diagnostic;
import ast::{required, provided}; import ast::{required, provided};
import ast_util::{operator_prec}; import ast_util::{operator_prec};
import dvec::dvec; import dvec::{DVec, dvec};
import parse::classify::*; import parse::classify::*;
import util::interner; import util::interner;
@ -35,7 +35,7 @@ type ps =
literals: option<~[comments::lit]>, literals: option<~[comments::lit]>,
mut cur_cmnt: uint, mut cur_cmnt: uint,
mut cur_lit: uint, mut cur_lit: uint,
boxes: dvec<pp::breaks>, boxes: DVec<pp::breaks>,
ann: pp_ann}; ann: pp_ann};
fn ibox(s: ps, u: uint) { fn ibox(s: ps, u: uint) {

View File

@ -3,11 +3,11 @@
// type, and vice versa. // type, and vice versa.
import std::map; import std::map;
import std::map::{hashmap, hashfn, eqfn}; import std::map::{hashmap, hashfn, eqfn};
import dvec::dvec; import dvec::{DVec, dvec};
type hash_interner<T: const> = type hash_interner<T: const> =
{map: hashmap<T, uint>, {map: hashmap<T, uint>,
vect: dvec<T>, vect: DVec<T>,
hasher: hashfn<T>, hasher: hashfn<T>,
eqer: eqfn<T>}; eqer: eqfn<T>};

View File

@ -9,7 +9,7 @@ import syntax::codemap::span;
import driver::session; import driver::session;
import session::session; import session::session;
import syntax::attr; import syntax::attr;
import dvec::dvec; import dvec::{DVec, dvec};
export modify_for_testing; export modify_for_testing;
@ -22,7 +22,7 @@ type test_ctxt =
@{sess: session::session, @{sess: session::session,
crate: @ast::crate, crate: @ast::crate,
mut path: ~[ast::ident], mut path: ~[ast::ident],
testfns: dvec<test>}; testfns: DVec<test>};
// Traverse the crate, collecting all the test functions, eliding any // Traverse the crate, collecting all the test functions, eliding any
// existing main functions, and synthesizing a main test harness // existing main functions, and synthesizing a main test harness

View File

@ -9,7 +9,7 @@ import std::map::{hashmap, int_hash};
import syntax::print::pprust; import syntax::print::pprust;
import filesearch::filesearch; import filesearch::filesearch;
import common::*; import common::*;
import dvec::dvec; import dvec::{DVec, dvec};
export read_crates; export read_crates;
@ -42,7 +42,7 @@ type cache_entry = {
metas: @~[@ast::meta_item] metas: @~[@ast::meta_item]
}; };
fn dump_crates(crate_cache: dvec<cache_entry>) { fn dump_crates(crate_cache: DVec<cache_entry>) {
debug!{"resolved crates:"}; debug!{"resolved crates:"};
for crate_cache.each |entry| { for crate_cache.each |entry| {
debug!{"cnum: %?", entry.cnum}; debug!{"cnum: %?", entry.cnum};
@ -67,9 +67,9 @@ fn warn_if_multiple_versions(diag: span_handler,
partition(crate_cache.map_to_vec(|entry| { partition(crate_cache.map_to_vec(|entry| {
let othername = loader::crate_name_from_metas(*entry.metas); let othername = loader::crate_name_from_metas(*entry.metas);
if name == othername { if name == othername {
left(entry) Left(entry)
} else { } else {
right(entry) Right(entry)
} }
})); }));
@ -96,7 +96,7 @@ type env = @{diag: span_handler,
cstore: cstore::cstore, cstore: cstore::cstore,
os: loader::os, os: loader::os,
static: bool, static: bool,
crate_cache: dvec<cache_entry>, crate_cache: DVec<cache_entry>,
mut next_crate_num: ast::crate_num}; mut next_crate_num: ast::crate_num};
fn visit_view_item(e: env, i: @ast::view_item) { fn visit_view_item(e: env, i: @ast::view_item) {
@ -114,11 +114,11 @@ fn visit_item(e: env, i: @ast::item) {
match i.node { match i.node {
ast::item_foreign_mod(m) => { ast::item_foreign_mod(m) => {
match attr::foreign_abi(i.attrs) { match attr::foreign_abi(i.attrs) {
either::right(abi) => { either::Right(abi) => {
if abi != ast::foreign_abi_cdecl && if abi != ast::foreign_abi_cdecl &&
abi != ast::foreign_abi_stdcall { return; } abi != ast::foreign_abi_stdcall { return; }
} }
either::left(msg) => e.diag.span_fatal(i.span, msg) either::Left(msg) => e.diag.span_fatal(i.span, msg)
} }
let cstore = e.cstore; let cstore = e.cstore;

View File

@ -10,7 +10,7 @@ import syntax::diagnostic::span_handler;
import syntax::diagnostic::expect; import syntax::diagnostic::expect;
import common::*; import common::*;
import std::map::hashmap; import std::map::hashmap;
import dvec::dvec; import dvec::{DVec, dvec};
export class_dtor; export class_dtor;
export get_symbol; export get_symbol;
@ -144,7 +144,7 @@ fn get_trait_methods(tcx: ty::ctxt, def: ast::def_id) -> @~[ty::method] {
} }
fn get_method_names_if_trait(cstore: cstore::cstore, def: ast::def_id) fn get_method_names_if_trait(cstore: cstore::cstore, def: ast::def_id)
-> option<@dvec<(@~str, ast::self_ty_)>> { -> option<@DVec<(@~str, ast::self_ty_)>> {
let cdata = cstore::get_crate_data(cstore, def.crate); let cdata = cstore::get_crate_data(cstore, def.crate);
return decoder::get_method_names_if_trait(cdata, def.node); return decoder::get_method_names_if_trait(cdata, def.node);

View File

@ -2,8 +2,8 @@
import std::{ebml, map}; import std::{ebml, map};
import std::map::{hashmap, str_hash}; import std::map::{hashmap, str_hash};
import dvec::dvec;
import io::WriterUtil; import io::WriterUtil;
import dvec::{DVec, dvec};
import syntax::{ast, ast_util}; import syntax::{ast, ast_util};
import syntax::attr; import syntax::attr;
import middle::ty; import middle::ty;
@ -684,7 +684,7 @@ fn get_trait_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
// their self types. Otherwise, returns none. This overlaps in an // their self types. Otherwise, returns none. This overlaps in an
// annoying way with get_trait_methods. // annoying way with get_trait_methods.
fn get_method_names_if_trait(cdata: cmd, node_id: ast::node_id) fn get_method_names_if_trait(cdata: cmd, node_id: ast::node_id)
-> option<@dvec<(@~str, ast::self_ty_)>> { -> option<@DVec<(@~str, ast::self_ty_)>> {
let item = lookup_item(node_id, cdata.data); let item = lookup_item(node_id, cdata.data);
if item_family(item) != 'I' { if item_family(item) != 'I' {

View File

@ -229,7 +229,7 @@ import syntax::print::pprust;
import util::common::indenter; import util::common::indenter;
import ty::to_str; import ty::to_str;
import driver::session::session; import driver::session::session;
import dvec::dvec; import dvec::{DVec, dvec};
import mem_categorization::*; import mem_categorization::*;
export check_crate, root_map, mutbl_map; export check_crate, root_map, mutbl_map;
@ -339,7 +339,7 @@ type loan = {lp: @loan_path, cmt: cmt, mutbl: ast::mutability};
/// - `pure_map`: map from block/expr that must be pure to the error message /// - `pure_map`: map from block/expr that must be pure to the error message
/// that should be reported if they are not pure /// that should be reported if they are not pure
type req_maps = { type req_maps = {
req_loan_map: hashmap<ast::node_id, @dvec<@dvec<loan>>>, req_loan_map: hashmap<ast::node_id, @DVec<@DVec<loan>>>,
pure_map: hashmap<ast::node_id, bckerr> pure_map: hashmap<ast::node_id, bckerr>
}; };

View File

@ -393,7 +393,7 @@ impl gather_loan_ctxt {
} }
} }
fn add_loans(scope_id: ast::node_id, loans: @dvec<loan>) { fn add_loans(scope_id: ast::node_id, loans: @DVec<loan>) {
match self.req_maps.req_loan_map.find(scope_id) { match self.req_maps.req_loan_map.find(scope_id) {
some(l) => { some(l) => {
(*l).push(loans); (*l).push(loans);

View File

@ -8,7 +8,7 @@ import result::{result, ok, err};
impl borrowck_ctxt { impl borrowck_ctxt {
fn loan(cmt: cmt, fn loan(cmt: cmt,
scope_region: ty::region, scope_region: ty::region,
mutbl: ast::mutability) -> bckres<@dvec<loan>> { mutbl: ast::mutability) -> bckres<@DVec<loan>> {
let lc = loan_ctxt_(@{bccx: self, let lc = loan_ctxt_(@{bccx: self,
scope_region: scope_region, scope_region: scope_region,
loans: @dvec()}); loans: @dvec()});
@ -26,7 +26,7 @@ type loan_ctxt_ = {
scope_region: ty::region, scope_region: ty::region,
// accumulated list of loans that will be required // accumulated list of loans that will be required
loans: @dvec<loan> loans: @DVec<loan>
}; };
enum loan_ctxt { enum loan_ctxt {

View File

@ -2,7 +2,7 @@ import syntax::ast::*;
import syntax::{visit, ast_util, ast_map}; import syntax::{visit, ast_util, ast_map};
import driver::session::session; import driver::session::session;
import std::map::hashmap; import std::map::hashmap;
import dvec::dvec; import dvec::{DVec, dvec};
fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map, fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map,
def_map: resolve3::DefMap, def_map: resolve3::DefMap,
@ -150,7 +150,7 @@ fn check_item_recursion(sess: session, ast_map: ast_map::map,
sess: session, sess: session,
ast_map: ast_map::map, ast_map: ast_map::map,
def_map: resolve3::DefMap, def_map: resolve3::DefMap,
idstack: @dvec<node_id>, idstack: @DVec<node_id>,
}; };
let env = { let env = {

View File

@ -415,7 +415,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
match it.node { match it.node {
ast::item_foreign_mod(nmod) if attr::foreign_abi(it.attrs) != ast::item_foreign_mod(nmod) if attr::foreign_abi(it.attrs) !=
either::right(ast::foreign_abi_rust_intrinsic) => { either::Right(ast::foreign_abi_rust_intrinsic) => {
for nmod.items.each |ni| { for nmod.items.each |ni| {
match ni.node { match ni.node {
ast::foreign_item_fn(decl, tps) => { ast::foreign_item_fn(decl, tps) => {

View File

@ -100,7 +100,7 @@
* - `self_var`: a variable representing 'self' * - `self_var`: a variable representing 'self'
*/ */
import dvec::dvec; import dvec::{DVec, dvec};
import std::map::{hashmap, int_hash, str_hash, box_str_hash}; import std::map::{hashmap, int_hash, str_hash, box_str_hash};
import syntax::{visit, ast_util}; import syntax::{visit, ast_util};
import syntax::print::pprust::{expr_to_str}; import syntax::print::pprust::{expr_to_str};
@ -122,7 +122,7 @@ export last_use_map;
// //
// Very subtle (#2633): borrowck will remove entries from this table // Very subtle (#2633): borrowck will remove entries from this table
// if it detects an outstanding loan (that is, the addr is taken). // if it detects an outstanding loan (that is, the addr is taken).
type last_use_map = hashmap<node_id, @dvec<node_id>>; type last_use_map = hashmap<node_id, @DVec<node_id>>;
enum variable = uint; enum variable = uint;
enum live_node = uint; enum live_node = uint;

View File

@ -14,7 +14,7 @@ import syntax::codemap::span;
import syntax::print::pprust; import syntax::print::pprust;
import syntax::ast_util::new_def_hash; import syntax::ast_util::new_def_hash;
import syntax::ast_map; import syntax::ast_map;
import dvec::dvec; import dvec::{DVec, dvec};
import metadata::csearch; import metadata::csearch;
import std::list; import std::list;
@ -343,7 +343,7 @@ fn resolve_crate(sess: session, def_map: resolve3::DefMap,
// dependencies until a fixed point is reached. // dependencies until a fixed point is reached.
type region_paramd_items = hashmap<ast::node_id, ()>; type region_paramd_items = hashmap<ast::node_id, ()>;
type dep_map = hashmap<ast::node_id, @dvec<ast::node_id>>; type dep_map = hashmap<ast::node_id, @DVec<ast::node_id>>;
type determine_rp_ctxt_ = { type determine_rp_ctxt_ = {
sess: session, sess: session,
@ -351,7 +351,7 @@ type determine_rp_ctxt_ = {
def_map: resolve3::DefMap, def_map: resolve3::DefMap,
region_paramd_items: region_paramd_items, region_paramd_items: region_paramd_items,
dep_map: dep_map, dep_map: dep_map,
worklist: dvec<ast::node_id>, worklist: DVec<ast::node_id>,
// the innermost enclosing item id // the innermost enclosing item id
mut item_id: ast::node_id, mut item_id: ast::node_id,

View File

@ -52,7 +52,7 @@ import syntax::visit::{visit_foreign_item, visit_item, visit_method_helper};
import syntax::visit::{visit_mod, visit_ty, vt}; import syntax::visit::{visit_mod, visit_ty, vt};
import box::ptr_eq; import box::ptr_eq;
import dvec::dvec; import dvec::{DVec, dvec};
import option::{get, is_some}; import option::{get, is_some};
import str::{connect, split_str}; import str::{connect, split_str};
import vec::pop; import vec::pop;
@ -89,7 +89,7 @@ type ImplScopes = @list<ImplScope>;
type ImplMap = hashmap<node_id,ImplScopes>; type ImplMap = hashmap<node_id,ImplScopes>;
// Trait method resolution // Trait method resolution
type TraitMap = @hashmap<node_id,@dvec<def_id>>; type TraitMap = @hashmap<node_id,@DVec<def_id>>;
// Export mapping // Export mapping
type Export = { reexp: bool, id: def_id }; type Export = { reexp: bool, id: def_id };
@ -116,7 +116,7 @@ enum NamespaceResult {
enum ImplNamespaceResult { enum ImplNamespaceResult {
UnknownImplResult, UnknownImplResult,
UnboundImplResult, UnboundImplResult,
BoundImplResult(@dvec<@Target>) BoundImplResult(@DVec<@Target>)
} }
enum NameDefinition { enum NameDefinition {
@ -250,7 +250,7 @@ fn Atom(n: uint) -> Atom {
class AtomTable { class AtomTable {
let atoms: hashmap<@~str,Atom>; let atoms: hashmap<@~str,Atom>;
let strings: dvec<@~str>; let strings: DVec<@~str>;
let mut atom_count: uint; let mut atom_count: uint;
new() { new() {
@ -326,11 +326,11 @@ class Rib {
/// One import directive. /// One import directive.
class ImportDirective { class ImportDirective {
let module_path: @dvec<Atom>; let module_path: @DVec<Atom>;
let subclass: @ImportDirectiveSubclass; let subclass: @ImportDirectiveSubclass;
let span: span; let span: span;
new(module_path: @dvec<Atom>, new(module_path: @DVec<Atom>,
subclass: @ImportDirectiveSubclass, subclass: @ImportDirectiveSubclass,
span: span) { span: span) {
@ -363,7 +363,7 @@ class ImportResolution {
let mut module_target: option<Target>; let mut module_target: option<Target>;
let mut value_target: option<Target>; let mut value_target: option<Target>;
let mut type_target: option<Target>; let mut type_target: option<Target>;
let mut impl_target: @dvec<@Target>; let mut impl_target: @DVec<@Target>;
let mut used: bool; let mut used: bool;
@ -409,7 +409,7 @@ class Module {
let mut def_id: option<def_id>; let mut def_id: option<def_id>;
let children: hashmap<Atom,@NameBindings>; let children: hashmap<Atom,@NameBindings>;
let imports: dvec<@ImportDirective>; let imports: DVec<@ImportDirective>;
// The anonymous children of this node. Anonymous children are pseudo- // The anonymous children of this node. Anonymous children are pseudo-
// modules that are implicitly created around items contained within // modules that are implicitly created around items contained within
@ -677,17 +677,17 @@ class Resolver {
// The current set of local scopes, for values. // The current set of local scopes, for values.
// XXX: Reuse ribs to avoid allocation. // XXX: Reuse ribs to avoid allocation.
let value_ribs: @dvec<@Rib>; let value_ribs: @DVec<@Rib>;
// The current set of local scopes, for types. // The current set of local scopes, for types.
let type_ribs: @dvec<@Rib>; let type_ribs: @DVec<@Rib>;
// Whether the current context is an X-ray context. An X-ray context is // Whether the current context is an X-ray context. An X-ray context is
// allowed to access private names of any module. // allowed to access private names of any module.
let mut xray_context: XrayFlag; let mut xray_context: XrayFlag;
// The trait that the current context can refer to. // The trait that the current context can refer to.
let mut current_trait_refs: option<@dvec<def_id>>; let mut current_trait_refs: option<@DVec<def_id>>;
// The atom for the keyword "self". // The atom for the keyword "self".
let self_atom: Atom; let self_atom: Atom;
@ -1571,7 +1571,7 @@ class Resolver {
/// Creates and adds an import directive to the given module. /// Creates and adds an import directive to the given module.
fn build_import_directive(module_: @Module, fn build_import_directive(module_: @Module,
module_path: @dvec<Atom>, module_path: @DVec<Atom>,
subclass: @ImportDirectiveSubclass, subclass: @ImportDirectiveSubclass,
span: span) { span: span) {
@ -2181,7 +2181,7 @@ class Resolver {
} }
fn resolve_module_path_from_root(module_: @Module, fn resolve_module_path_from_root(module_: @Module,
module_path: @dvec<Atom>, module_path: @DVec<Atom>,
index: uint, index: uint,
xray: XrayFlag, xray: XrayFlag,
span: span) span: span)
@ -2238,7 +2238,7 @@ class Resolver {
* the given module. * the given module.
*/ */
fn resolve_module_path_for_import(module_: @Module, fn resolve_module_path_for_import(module_: @Module,
module_path: @dvec<Atom>, module_path: @DVec<Atom>,
xray: XrayFlag, xray: XrayFlag,
span: span) span: span)
-> ResolveResult<@Module> { -> ResolveResult<@Module> {
@ -2932,7 +2932,7 @@ class Resolver {
// Wraps the given definition in the appropriate number of `def_upvar` // Wraps the given definition in the appropriate number of `def_upvar`
// wrappers. // wrappers.
fn upvarify(ribs: @dvec<@Rib>, rib_index: uint, def_like: def_like, fn upvarify(ribs: @DVec<@Rib>, rib_index: uint, def_like: def_like,
span: span, allow_capturing_self: AllowCapturingSelfFlag) span: span, allow_capturing_self: AllowCapturingSelfFlag)
-> option<def_like> { -> option<def_like> {
@ -3031,7 +3031,7 @@ class Resolver {
return some(dl_def(def)); return some(dl_def(def));
} }
fn search_ribs(ribs: @dvec<@Rib>, name: Atom, span: span, fn search_ribs(ribs: @DVec<@Rib>, name: Atom, span: span,
allow_capturing_self: AllowCapturingSelfFlag) allow_capturing_self: AllowCapturingSelfFlag)
-> option<def_like> { -> option<def_like> {
@ -4150,7 +4150,7 @@ class Resolver {
} }
} }
fn intern_module_part_of_path(path: @path) -> @dvec<Atom> { fn intern_module_part_of_path(path: @path) -> @DVec<Atom> {
let module_path_atoms = @dvec(); let module_path_atoms = @dvec();
for path.idents.eachi |index, ident| { for path.idents.eachi |index, ident| {
if index == path.idents.len() - 1u { if index == path.idents.len() - 1u {
@ -4508,7 +4508,7 @@ class Resolver {
} }
} }
fn search_for_traits_containing_method(name: Atom) -> @dvec<def_id> { fn search_for_traits_containing_method(name: Atom) -> @DVec<def_id> {
let found_traits = @dvec(); let found_traits = @dvec();
let mut search_module = self.current_module; let mut search_module = self.current_module;
loop { loop {
@ -4577,7 +4577,7 @@ class Resolver {
return found_traits; return found_traits;
} }
fn add_trait_info_if_containing_method(found_traits: @dvec<def_id>, fn add_trait_info_if_containing_method(found_traits: @DVec<def_id>,
trait_def_id: def_id, trait_def_id: def_id,
name: Atom) { name: Atom) {

View File

@ -13,7 +13,7 @@ import syntax::print::pprust::pat_to_str;
import middle::resolve3::DefMap; import middle::resolve3::DefMap;
import back::abi; import back::abi;
import std::map::hashmap; import std::map::hashmap;
import dvec::dvec; import dvec::{DVec, dvec};
import common::*; import common::*;
@ -277,7 +277,7 @@ fn enter_uniq(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef)
} }
fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] { fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] {
fn add_to_set(tcx: ty::ctxt, &&set: dvec<opt>, val: opt) { fn add_to_set(tcx: ty::ctxt, &&set: DVec<opt>, val: opt) {
if set.any(|l| opt_eq(tcx, l, val)) {return;} if set.any(|l| opt_eq(tcx, l, val)) {return;}
set.push(val); set.push(val);
} }

View File

@ -5015,8 +5015,8 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
ast::item_const(_, expr) => consts::trans_const(ccx, expr, item.id), ast::item_const(_, expr) => consts::trans_const(ccx, expr, item.id),
ast::item_foreign_mod(foreign_mod) => { ast::item_foreign_mod(foreign_mod) => {
let abi = match attr::foreign_abi(item.attrs) { let abi = match attr::foreign_abi(item.attrs) {
either::right(abi_) => abi_, either::Right(abi_) => abi_,
either::left(msg) => ccx.sess.span_fatal(item.span, msg) either::Left(msg) => ccx.sess.span_fatal(item.span, msg)
}; };
foreign::trans_foreign_mod(ccx, foreign_mod, abi); foreign::trans_foreign_mod(ccx, foreign_mod, abi);
} }

View File

@ -1168,8 +1168,8 @@ fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item)
ast_map::node_foreign_item(_, abi, _) => abi ast_map::node_foreign_item(_, abi, _) => abi
}, },
some(_) => match attr::foreign_abi(i.attrs) { some(_) => match attr::foreign_abi(i.attrs) {
either::right(abi) => abi, either::Right(abi) => abi,
either::left(msg) => ccx.sess.span_fatal(i.span, msg) either::Left(msg) => ccx.sess.span_fatal(i.span, msg)
} }
} }
} }

View File

@ -15,7 +15,7 @@ import syntax::ast_util::{dummy_sp, new_def_hash};
import syntax::util::interner; import syntax::util::interner;
import util::ppaux::ty_to_str; import util::ppaux::ty_to_str;
import syntax::codemap::span; import syntax::codemap::span;
import dvec::dvec; import dvec::{DVec, dvec};
import std::map::hashmap; import std::map::hashmap;
import option::is_some; import option::is_some;
@ -65,7 +65,7 @@ type ctxt =
{mut next_tag_id: u16, {mut next_tag_id: u16,
pad: u16, pad: u16,
tag_id_to_index: hashmap<nominal_id, u16>, tag_id_to_index: hashmap<nominal_id, u16>,
tag_order: dvec<enum_data>, tag_order: DVec<enum_data>,
resources: interner::interner<nominal_id>, resources: interner::interner<nominal_id>,
llshapetablesty: TypeRef, llshapetablesty: TypeRef,
llshapetables: ValueRef}; llshapetables: ValueRef};

View File

@ -501,7 +501,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
} }
ast::item_foreign_mod(m) => { ast::item_foreign_mod(m) => {
if syntax::attr::foreign_abi(it.attrs) == if syntax::attr::foreign_abi(it.attrs) ==
either::right(ast::foreign_abi_rust_intrinsic) { either::Right(ast::foreign_abi_rust_intrinsic) {
for m.items.each |item| { for m.items.each |item| {
check_intrinsic_type(ccx, item); check_intrinsic_type(ccx, item);
} }

View File

@ -9,7 +9,7 @@ import syntax::ast::{sty_value};
import syntax::ast_map; import syntax::ast_map;
import syntax::ast_map::node_id_to_str; import syntax::ast_map::node_id_to_str;
import syntax::ast_util::{dummy_sp, new_def_hash}; import syntax::ast_util::{dummy_sp, new_def_hash};
import dvec::dvec; import dvec::{DVec, dvec};
type candidate = { type candidate = {
self_ty: ty::t, // type of a in a.b() self_ty: ty::t, // type of a in a.b()
@ -57,7 +57,7 @@ class lookup {
let m_name: ast::ident; let m_name: ast::ident;
let mut self_ty: ty::t; let mut self_ty: ty::t;
let mut derefs: uint; let mut derefs: uint;
let candidates: dvec<candidate>; let candidates: DVec<candidate>;
let candidate_impls: hashmap<def_id, ()>; let candidate_impls: hashmap<def_id, ()>;
let supplied_tps: ~[ty::t]; let supplied_tps: ~[ty::t];
let include_private: bool; let include_private: bool;
@ -435,7 +435,7 @@ class lookup {
} }
fn add_inherent_and_extension_candidates(optional_inherent_methods: fn add_inherent_and_extension_candidates(optional_inherent_methods:
option<@dvec<@Impl>>, option<@DVec<@Impl>>,
use_assignability: bool) { use_assignability: bool) {
// Add inherent methods. // Add inherent methods.

View File

@ -30,7 +30,7 @@ import syntax::visit::{mk_simple_visitor, mk_vt, visit_crate, visit_item};
import syntax::visit::{visit_mod}; import syntax::visit::{visit_mod};
import util::ppaux::ty_to_str; import util::ppaux::ty_to_str;
import dvec::dvec; import dvec::{DVec, dvec};
import result::ok; import result::ok;
import std::map::{hashmap, int_hash}; import std::map::{hashmap, int_hash};
import uint::range; import uint::range;
@ -121,11 +121,11 @@ fn method_to_MethodInfo(ast_method: @method) -> @MethodInfo {
class CoherenceInfo { class CoherenceInfo {
// Contains implementations of methods that are inherent to a type. // Contains implementations of methods that are inherent to a type.
// Methods in these implementations don't need to be exported. // Methods in these implementations don't need to be exported.
let inherent_methods: hashmap<def_id,@dvec<@Impl>>; let inherent_methods: hashmap<def_id,@DVec<@Impl>>;
// Contains implementations of methods associated with a trait. For these, // Contains implementations of methods associated with a trait. For these,
// the associated trait must be imported at the call site. // the associated trait must be imported at the call site.
let extension_methods: hashmap<def_id,@dvec<@Impl>>; let extension_methods: hashmap<def_id,@DVec<@Impl>>;
new() { new() {
self.inherent_methods = new_def_hash(); self.inherent_methods = new_def_hash();
@ -356,7 +356,7 @@ class CoherenceChecker {
} }
fn check_implementation_coherence(_trait_def_id: def_id, fn check_implementation_coherence(_trait_def_id: def_id,
implementations: @dvec<@Impl>) { implementations: @DVec<@Impl>) {
// Unify pairs of polytypes. // Unify pairs of polytypes.
for range(0, implementations.len()) |i| { for range(0, implementations.len()) |i| {
@ -540,7 +540,7 @@ class CoherenceChecker {
return trait_id; return trait_id;
} }
fn gather_privileged_types(items: ~[@item]) -> @dvec<def_id> { fn gather_privileged_types(items: ~[@item]) -> @DVec<def_id> {
let results = @dvec(); let results = @dvec();
for items.each |item| { for items.each |item| {
match item.node { match item.node {

View File

@ -262,7 +262,7 @@ import driver::session::session;
import util::common::{indent, indenter}; import util::common::{indent, indenter};
import ast::{unsafe_fn, impure_fn, pure_fn, extern_fn}; import ast::{unsafe_fn, impure_fn, pure_fn, extern_fn};
import ast::{m_const, m_imm, m_mutbl}; import ast::{m_const, m_imm, m_mutbl};
import dvec::dvec; import dvec::{DVec, dvec};
export infer_ctxt; export infer_ctxt;
export new_infer_ctxt; export new_infer_ctxt;
@ -402,7 +402,7 @@ enum infer_ctxt = @{
ty_var_integral_counter: @mut uint, ty_var_integral_counter: @mut uint,
region_var_counter: @mut uint, region_var_counter: @mut uint,
borrowings: dvec<{expr_id: ast::node_id, borrowings: DVec<{expr_id: ast::node_id,
span: span, span: span,
scope: ty::region, scope: ty::region,
mutbl: ast::mutability}> mutbl: ast::mutability}>

View File

@ -1,7 +1,7 @@
import dvec::dvec; import dvec::{DVec, dvec};
type entry<A,B> = {key: A, value: B}; type entry<A,B> = {key: A, value: B};
type alist<A,B> = { eq_fn: fn@(A,A) -> bool, data: dvec<entry<A,B>> }; type alist<A,B> = { eq_fn: fn@(A,A) -> bool, data: DVec<entry<A,B>> };
fn alist_add<A: copy, B: copy>(lst: alist<A,B>, k: A, v: B) { fn alist_add<A: copy, B: copy>(lst: alist<A,B>, k: A, v: B) {
lst.data.push({key:k, value:v}); lst.data.push({key:k, value:v});

View File

@ -4,10 +4,10 @@
use std; use std;
import dvec::*; import dvec::*;
import dvec::dvec; import dvec::DVec;
import std::map::hashmap; import std::map::hashmap;
type header_map = hashmap<~str, @dvec<@~str>>; type header_map = hashmap<~str, @DVec<@~str>>;
// the unused ty param is necessary so this gets monomorphized // the unused ty param is necessary so this gets monomorphized
fn request<T: copy>(req: header_map) { fn request<T: copy>(req: header_map) {

View File

@ -1,7 +1,7 @@
import dvec::dvec; import dvec::DVec;
type parser = { type parser = {
tokens: dvec<int>, tokens: DVec<int>,
}; };
trait parse { trait parse {

View File

@ -2,7 +2,7 @@ mod argparse {
use std; use std;
import std::map; import std::map;
import either::{either, left, right}; import either::{Either, Left, Right};
struct Flag { struct Flag {
name: &str; name: &str;

View File

@ -79,8 +79,8 @@ fn test_select2() {
stream::client::send(ac, 42); stream::client::send(ac, 42);
match pipes::select2(ap, bp) { match pipes::select2(ap, bp) {
either::left(*) => { } either::Left(*) => { }
either::right(*) => { fail } either::Right(*) => { fail }
} }
stream::client::send(bc, ~"abc"); stream::client::send(bc, ~"abc");
@ -93,8 +93,8 @@ fn test_select2() {
stream::client::send(bc, ~"abc"); stream::client::send(bc, ~"abc");
match pipes::select2(ap, bp) { match pipes::select2(ap, bp) {
either::left(*) => { fail } either::Left(*) => { fail }
either::right(*) => { } either::Right(*) => { }
} }
stream::client::send(ac, 42); stream::client::send(ac, 42);

View File

@ -49,7 +49,7 @@ pure fn build<A, B: buildable<A>>(builder: fn(push: pure fn(+A))) -> B {
} }
/// Apply a function to each element of an iterable and return the results /// Apply a function to each element of an iterable and return the results
fn map<T, IT: base_iter<T>, U, BU: buildable<U>> fn map<T, IT: BaseIter<T>, U, BU: buildable<U>>
(v: IT, f: fn(T) -> U) -> BU { (v: IT, f: fn(T) -> U) -> BU {
do build |push| { do build |push| {
for v.each() |elem| { for v.each() |elem| {