Convert all kind bounds to camel case. Remove send, owned keywords.

This commit is contained in:
Brian Anderson 2012-09-07 14:52:28 -07:00
parent 07fe5611ad
commit 3bd1f32cd9
167 changed files with 613 additions and 622 deletions

View File

@ -449,7 +449,7 @@ Two examples of paths with type arguments:
~~~~
# use std::map;
# fn f() {
# fn id<T:copy>(t: T) -> T { t }
# fn id<T:Copy>(t: T) -> T { t }
type t = map::hashmap<int,~str>; // Type arguments used in a type expression
let x = id::<int>(10); // Type arguments used in a call expression
# }
@ -1056,7 +1056,7 @@ An example of a pure function that uses an unchecked block:
~~~~
# use std::list::*;
fn pure_foldl<T, U: copy>(ls: List<T>, u: U, f: fn(&&T, &&U) -> U) -> U {
fn pure_foldl<T, U: Copy>(ls: List<T>, u: U, f: fn(&&T, &&U) -> U) -> U {
match ls {
Nil => u,
Cons(hd, tl) => f(hd, pure_foldl(*tl, f(hd, u), f))
@ -1110,7 +1110,7 @@ type can always be moved, but they can only be copied when the
parameter is given a [`copy` bound](#type-kinds).
~~~~
fn id<T: copy>(x: T) -> T { x }
fn id<T: Copy>(x: T) -> T { x }
~~~~
Similarly, [trait](#traits) bounds can be specified for type
@ -2638,7 +2638,7 @@ Every struct item defines a type.
Within the body of an item that has type parameter declarations, the names of its type parameters are types:
~~~~~~~
fn map<A: copy, B: copy>(f: fn(A) -> B, xs: ~[A]) -> ~[B] {
fn map<A: Copy, B: Copy>(f: fn(A) -> B, xs: ~[A]) -> ~[B] {
if xs.len() == 0 { return ~[]; }
let first: B = f(xs[0]);
let rest: ~[B] = map(f, xs.slice(1, xs.len()));
@ -2706,7 +2706,7 @@ Putting `x` into a shared box involves copying, and the `T` parameter
is assumed to be noncopyable. To change that, a bound is declared:
~~~~
fn box<T: copy>(x: T) -> @T { @x }
fn box<T: Copy>(x: T) -> @T { @x }
~~~~
Calling this second version of `box` on a noncopyable type is not

View File

@ -1583,20 +1583,20 @@ unless you explicitly declare that type parameter to have copyable
// This does not compile
fn head_bad<T>(v: ~[T]) -> T { v[0] }
// This does
fn head<T: copy>(v: ~[T]) -> T { v[0] }
fn head<T: Copy>(v: ~[T]) -> T { v[0] }
~~~~
When instantiating a generic function, you can only instantiate it
with types that fit its kinds. So you could not apply `head` to a
resource type. Rust has several kinds that can be used as type bounds:
* `copy` - Copyable types. All types are copyable unless they
* `Copy` - Copyable types. All types are copyable unless they
are classes with destructors or otherwise contain
classes with destructors.
* `send` - Sendable types. All types are sendable unless they
* `Send` - Sendable types. All types are sendable unless they
contain shared boxes, closures, or other local-heap-allocated
types.
* `const` - Constant types. These are types that do not contain
* `Const` - Constant types. These are types that do not contain
mutable fields nor shared boxes.
> ***Note:*** Rust type kinds are syntactically very similar to
@ -2002,7 +2002,7 @@ and one for values. This means that this code is valid:
~~~~
mod buffalo {
type buffalo = int;
fn buffalo<buffalo: copy>(buffalo: buffalo) -> buffalo { buffalo }
fn buffalo<buffalo>(+buffalo: buffalo) -> buffalo { buffalo }
}
fn main() {
let buffalo: buffalo::buffalo = 1;

View File

@ -239,7 +239,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: codemap::codemap,
pprust::ty_to_str, replace_ty_in_crate, cx);
}
fn check_variants_T<T: copy>(
fn check_variants_T<T: Copy>(
crate: ast::crate,
codemap: codemap::codemap,
filename: &Path,

View File

@ -89,7 +89,7 @@ pure fn build_sized_opt<A>(size: Option<uint>,
// Appending
#[inline(always)]
pure fn append<T: copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
do build_sized(lhs.len() + rhs.len()) |push| {
for vec::each(lhs) |x| { push(x); }
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
@ -125,7 +125,7 @@ pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
* Creates an immutable vector of size `n_elts` and initializes the elements
* to the value `t`.
*/
pure fn from_elem<T: copy>(n_elts: uint, t: T) -> @[T] {
pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
do build_sized(n_elts) |push| {
let mut i: uint = 0u;
while i < n_elts { push(t); i += 1u; }
@ -133,7 +133,7 @@ pure fn from_elem<T: copy>(n_elts: uint, t: T) -> @[T] {
}
#[cfg(notest)]
impl<T: copy> @[T]: Add<&[const T],@[T]> {
impl<T: Copy> @[T]: Add<&[const T],@[T]> {
#[inline(always)]
pure fn add(rhs: &[const T]) -> @[T] {
append(self, rhs)

View File

@ -48,7 +48,7 @@ export listen;
* transmitted. If a port value is copied, both copies refer to the same
* port. Ports may be associated with multiple `chan`s.
*/
enum Port<T: send> {
enum Port<T: Send> {
Port_(@PortPtr<T>)
}
@ -64,16 +64,16 @@ enum Port<T: send> {
* data will be silently dropped. Channels may be duplicated and
* themselves transmitted over other channels.
*/
enum Chan<T: send> {
enum Chan<T: Send> {
Chan_(port_id)
}
/// Constructs a port
fn Port<T: send>() -> Port<T> {
fn Port<T: Send>() -> Port<T> {
Port_(@PortPtr(rustrt::new_port(sys::size_of::<T>() as size_t)))
}
impl<T: send> Port<T> {
impl<T: Send> Port<T> {
fn chan() -> Chan<T> { Chan(self) }
fn send(+v: T) { self.chan().send(v) }
@ -82,7 +82,7 @@ impl<T: send> Port<T> {
}
impl<T: send> Chan<T> {
impl<T: Send> Chan<T> {
fn chan() -> Chan<T> { self }
fn send(+v: T) { send(self, v) }
@ -92,12 +92,12 @@ impl<T: send> Chan<T> {
}
/// Open a new receiving channel for the duration of a function
fn listen<T: send, U>(f: fn(Chan<T>) -> U) -> U {
fn listen<T: Send, U>(f: fn(Chan<T>) -> U) -> U {
let po = Port();
f(po.chan())
}
struct PortPtr<T:send> {
struct PortPtr<T:Send> {
po: *rust_port,
drop unsafe {
do task::unkillable {
@ -121,7 +121,7 @@ struct PortPtr<T:send> {
}
}
fn PortPtr<T: send>(po: *rust_port) -> PortPtr<T> {
fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> {
PortPtr {
po: po
}
@ -135,7 +135,7 @@ fn PortPtr<T: send>(po: *rust_port) -> PortPtr<T> {
* Fails if the port is detached or dead. Fails if the port
* is owned by a different task.
*/
fn as_raw_port<T: send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
struct PortRef {
p: *rust_port,
@ -167,7 +167,7 @@ fn as_raw_port<T: send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
* Constructs a channel. The channel is bound to the port used to
* construct it.
*/
fn Chan<T: send>(p: Port<T>) -> Chan<T> {
fn Chan<T: Send>(p: Port<T>) -> Chan<T> {
Chan_(rustrt::get_port_id((**p).po))
}
@ -175,7 +175,7 @@ fn Chan<T: send>(p: Port<T>) -> Chan<T> {
* Sends data over a channel. The sent data is moved into the channel,
* whereupon the caller loses access to it.
*/
fn send<T: send>(ch: Chan<T>, +data: T) {
fn send<T: Send>(ch: Chan<T>, +data: T) {
let Chan_(p) = ch;
let data_ptr = ptr::addr_of(data) as *();
let res = rustrt::rust_port_id_send(p, data_ptr);
@ -190,22 +190,22 @@ fn send<T: send>(ch: Chan<T>, +data: T) {
* Receive from a port. If no data is available on the port then the
* task will block until data becomes available.
*/
fn recv<T: send>(p: Port<T>) -> T { recv_((**p).po) }
fn recv<T: Send>(p: Port<T>) -> T { recv_((**p).po) }
/// Returns true if there are messages available
fn peek<T: send>(p: Port<T>) -> bool { peek_((**p).po) }
fn peek<T: Send>(p: Port<T>) -> bool { peek_((**p).po) }
#[doc(hidden)]
fn recv_chan<T: send>(ch: comm::Chan<T>) -> T {
fn recv_chan<T: Send>(ch: comm::Chan<T>) -> T {
as_raw_port(ch, |x|recv_(x))
}
fn peek_chan<T: send>(ch: comm::Chan<T>) -> bool {
fn peek_chan<T: Send>(ch: comm::Chan<T>) -> bool {
as_raw_port(ch, |x|peek_(x))
}
/// Receive on a raw port pointer
fn recv_<T: send>(p: *rust_port) -> T {
fn recv_<T: Send>(p: *rust_port) -> T {
let yield = 0u;
let yieldp = ptr::addr_of(yield);
let mut res;
@ -231,7 +231,7 @@ fn peek_(p: *rust_port) -> bool {
}
/// 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> {
let ports = ~[(**p_a).po, (**p_b).po];
let yield = 0u, yieldp = ptr::addr_of(yield);

View File

@ -96,7 +96,7 @@ pure fn from_elem<T>(+data: T) -> DList<T> {
list
}
fn from_vec<T: copy>(+vec: &[T]) -> DList<T> {
fn from_vec<T: Copy>(+vec: &[T]) -> DList<T> {
do vec::foldl(DList(), vec) |list,data| {
list.push(data); // Iterating left-to-right -- add newly to the tail.
list
@ -417,7 +417,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).
fn pop() -> Option<T> { self.pop_n().map (|nobe| nobe.data) }
/// Remove data from the tail of the list. O(1).

View File

@ -210,7 +210,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
*
@ -327,7 +327,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 {
self.get_elt(idx)
}

View File

@ -29,7 +29,7 @@ fn either<T, U, V>(f_left: fn((&T)) -> V,
}
}
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
let mut result: ~[T] = ~[];
@ -42,7 +42,7 @@ fn lefts<T: copy, U>(eithers: &[Either<T, U>]) -> ~[T] {
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
let mut result: ~[U] = ~[];
@ -55,7 +55,7 @@ fn rights<T, U: copy>(eithers: &[Either<T, U>]) -> ~[U] {
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]} {
/*!
* Extracts from a vector of either all the left values and right values
@ -75,7 +75,7 @@ fn partition<T: copy, U: copy>(eithers: &[Either<T, U>])
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
match *eith {
@ -84,7 +84,7 @@ pure fn flip<T: copy, U: copy>(eith: &Either<T, U>) -> Either<U, T> {
}
}
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
*

View File

@ -43,7 +43,7 @@ priv enum FutureState<A> {
}
/// Methods on the `future` type
impl<A:copy> Future<A> {
impl<A:Copy> Future<A> {
fn get() -> A {
//! Get the value of the future
@ -74,7 +74,7 @@ fn from_value<A>(+val: A) -> Future<A> {
Future {state: Forced(val)}
}
fn from_port<A:send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
/*!
* Create a future from a port
*
@ -105,7 +105,7 @@ fn from_fn<A>(+f: @fn() -> A) -> Future<A> {
Future {state: Pending(f)}
}
fn spawn<A:send>(+blk: fn~() -> A) -> Future<A> {
fn spawn<A:Send>(+blk: fn~() -> A) -> Future<A> {
/*!
* Create a future from a unique closure.
*
@ -156,7 +156,7 @@ fn get_ref<A>(future: &r/Future<A>) -> &r/A {
}
}
fn get<A:copy>(future: &Future<A>) -> A {
fn get<A:Copy>(future: &Future<A>) -> A {
//! Get the value of the future
*get_ref(future)
@ -169,7 +169,7 @@ fn with<A,B>(future: &Future<A>, blk: fn((&A)) -> B) -> B {
}
proto! future_pipe (
waiting:recv<T:send> {
waiting:recv<T:Send> {
completed(T) -> !
}
)

View File

@ -28,7 +28,7 @@ impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
}
}
impl<A: copy> IMPL_T<A>: iter::CopyableIter<A> {
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred)
}
@ -45,7 +45,7 @@ impl<A: copy> IMPL_T<A>: iter::CopyableIter<A> {
pure fn find(p: fn(A) -> bool) -> Option<A> { iter::find(self, p) }
}
impl<A: copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<A> {
impl<A: Copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<A> {
pure fn min() -> A { iter::min(self) }
pure fn max() -> A { iter::max(self) }
}

View File

@ -28,14 +28,14 @@ trait TimesIx{
pure fn timesi(it: fn(uint) -> bool);
}
trait CopyableIter<A:copy> {
trait CopyableIter<A:Copy> {
pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A];
pure fn map_to_vec<B>(op: fn(A) -> B) -> ~[B];
pure fn to_vec() -> ~[A];
pure fn find(p: fn(A) -> bool) -> Option<A>;
}
trait CopyableOrderedIter<A:copy Ord> {
trait CopyableOrderedIter<A:Copy Ord> {
pure fn min() -> A;
pure fn max() -> A;
}
@ -82,7 +82,7 @@ pure fn any<A,IA:BaseIter<A>>(self: IA, blk: fn(A) -> bool) -> bool {
return false;
}
pure fn filter_to_vec<A:copy,IA:BaseIter<A>>(self: IA,
pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>(self: IA,
prd: fn(A) -> bool) -> ~[A] {
do vec::build_sized_opt(self.size_hint()) |push| {
for self.each |a| {
@ -91,7 +91,7 @@ pure fn filter_to_vec<A:copy,IA:BaseIter<A>>(self: IA,
}
}
pure fn map_to_vec<A:copy,B,IA:BaseIter<A>>(self: IA, op: fn(A) -> B)
pure fn map_to_vec<A:Copy,B,IA:BaseIter<A>>(self: IA, op: fn(A) -> B)
-> ~[B] {
do vec::build_sized_opt(self.size_hint()) |push| {
for self.each |a| {
@ -100,7 +100,7 @@ pure fn map_to_vec<A:copy,B,IA:BaseIter<A>>(self: IA, op: fn(A) -> B)
}
}
pure fn flat_map_to_vec<A:copy,B:copy,IA:BaseIter<A>,IB:BaseIter<B>>(
pure fn flat_map_to_vec<A:Copy,B:Copy,IA:BaseIter<A>,IB:BaseIter<B>>(
self: IA, op: fn(A) -> IB) -> ~[B] {
do vec::build |push| {
@ -120,7 +120,7 @@ pure fn foldl<A,B,IA:BaseIter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
return b;
}
pure fn to_vec<A:copy,IA:BaseIter<A>>(self: IA) -> ~[A] {
pure fn to_vec<A:Copy,IA:BaseIter<A>>(self: IA) -> ~[A] {
foldl::<A,~[A],IA>(self, ~[], |r, a| vec::append(copy r, ~[a]))
}
@ -163,7 +163,7 @@ pure fn repeat(times: uint, blk: fn() -> bool) {
}
}
pure fn min<A:copy Ord,IA:BaseIter<A>>(self: IA) -> A {
pure fn min<A:Copy Ord,IA:BaseIter<A>>(self: IA) -> A {
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
match a {
Some(a_) if a_ < b => {
@ -179,7 +179,7 @@ pure fn min<A:copy Ord,IA:BaseIter<A>>(self: IA) -> A {
}
}
pure fn max<A:copy,IA:BaseIter<A>>(self: IA) -> A {
pure fn max<A:Copy,IA:BaseIter<A>>(self: IA) -> A {
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
match a {
Some(a_) if a_ > b => {
@ -195,7 +195,7 @@ pure fn max<A:copy,IA:BaseIter<A>>(self: IA) -> A {
}
}
pure fn find<A: copy,IA:BaseIter<A>>(self: IA,
pure fn find<A: Copy,IA:BaseIter<A>>(self: IA,
p: fn(A) -> bool) -> Option<A> {
for self.each |i| {
if p(i) { return Some(i) }
@ -271,7 +271,7 @@ pure fn from_fn<T,BT: Buildable<T>>(n_elts: uint, op: InitOp<T>) -> BT {
* Creates an immutable vector of size `n_elts` and initializes the elements
* to the value `t`.
*/
pure fn from_elem<T: copy,BT: Buildable<T>>(n_elts: uint, t: T) -> BT {
pure fn from_elem<T: Copy,BT: Buildable<T>>(n_elts: uint, t: T) -> BT {
do build_sized(n_elts) |push| {
let mut i: uint = 0u;
while i < n_elts { push(t); i += 1u; }
@ -280,7 +280,7 @@ pure fn from_elem<T: copy,BT: Buildable<T>>(n_elts: uint, t: T) -> BT {
/// Appending two generic sequences
#[inline(always)]
pure fn append<T: copy,IT: BaseIter<T>,BT: Buildable<T>>(
pure fn append<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>(
lhs: IT, rhs: IT) -> BT {
let size_opt = lhs.size_hint().chain(
|sz1| rhs.size_hint().map(|sz2| sz1+sz2));
@ -293,7 +293,7 @@ pure fn append<T: copy,IT: BaseIter<T>,BT: Buildable<T>>(
/// Copies a generic sequence, possibly converting it to a different
/// type of sequence.
#[inline(always)]
pure fn copy_seq<T: copy,IT: BaseIter<T>,BT: Buildable<T>>(
pure fn copy_seq<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>(
v: IT) -> BT {
do build_sized_opt(v.size_hint()) |push| {
for v.each |x| { push(x); }

View File

@ -16,7 +16,7 @@ enum Option<T> {
Some(T),
}
pure fn get<T: copy>(opt: Option<T>) -> T {
pure fn get<T: Copy>(opt: Option<T>) -> T {
/*!
* Gets the value out of an option
*
@ -45,7 +45,7 @@ pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
}
}
pure fn expect<T: copy>(opt: Option<T>, reason: ~str) -> T {
pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T {
/*!
* Gets the value out of an option, printing a specified message on
* failure
@ -128,7 +128,7 @@ pure fn is_some<T>(opt: Option<T>) -> bool {
!is_none(opt)
}
pure fn get_default<T: copy>(opt: Option<T>, def: T) -> T {
pure fn get_default<T: Copy>(opt: Option<T>, def: T) -> T {
//! Returns the contained value or a default
match opt { Some(x) => x, None => def }
@ -226,7 +226,7 @@ impl<T> &Option<T> {
pure fn get_ref() -> &self/T { get_ref(self) }
}
impl<T: copy> Option<T> {
impl<T: Copy> Option<T> {
/**
* Gets the value out of an option
*

View File

@ -152,7 +152,7 @@ fn buffer_header() -> BufferHeader { BufferHeader() }
// This is for protocols to associate extra data to thread around.
#[doc(hidden)]
type Buffer<T: send> = {
type Buffer<T: Send> = {
header: BufferHeader,
data: T,
};
@ -191,7 +191,7 @@ struct PacketHeader {
reinterpret_cast(&self.buffer)
}
fn set_buffer<T: send>(b: ~Buffer<T>) unsafe {
fn set_buffer<T: Send>(b: ~Buffer<T>) unsafe {
self.buffer = reinterpret_cast(&b);
}
}
@ -205,7 +205,7 @@ fn PacketHeader() -> PacketHeader {
}
#[doc(hidden)]
type Packet<T: send> = {
type Packet<T: Send> = {
header: PacketHeader,
mut payload: Option<T>,
};
@ -213,7 +213,7 @@ type Packet<T: send> = {
// XXX remove me
#[cfg(stage0)]
#[allow(non_camel_case_types)]
type packet<T: send> = Packet<T>;
type packet<T: Send> = Packet<T>;
#[doc(hidden)]
trait HasBuffer {
@ -221,7 +221,7 @@ trait HasBuffer {
fn set_buffer_(b: *libc::c_void);
}
impl<T: send> Packet<T>: HasBuffer {
impl<T: Send> Packet<T>: HasBuffer {
fn set_buffer_(b: *libc::c_void) {
self.header.buffer = b;
}
@ -235,14 +235,14 @@ trait has_buffer {
}
#[cfg(stage0)] // XXX remove me
impl<T: send> packet<T>: has_buffer {
impl<T: Send> packet<T>: has_buffer {
fn set_buffer(b: *libc::c_void) {
self.header.buffer = b;
}
}
#[doc(hidden)]
fn mk_packet<T: send>() -> Packet<T> {
fn mk_packet<T: Send>() -> Packet<T> {
{
header: PacketHeader(),
mut payload: None
@ -250,7 +250,7 @@ fn mk_packet<T: send>() -> Packet<T> {
}
#[doc(hidden)]
fn unibuffer<T: send>() -> ~Buffer<Packet<T>> {
fn unibuffer<T: Send>() -> ~Buffer<Packet<T>> {
let b = ~{
header: BufferHeader(),
data: {
@ -267,7 +267,7 @@ fn unibuffer<T: send>() -> ~Buffer<Packet<T>> {
}
#[doc(hidden)]
fn packet<T: send>() -> *Packet<T> {
fn packet<T: Send>() -> *Packet<T> {
let b = unibuffer();
let p = ptr::addr_of(b.data);
// We'll take over memory management from here.
@ -276,7 +276,7 @@ fn packet<T: send>() -> *Packet<T> {
}
#[doc(hidden)]
fn entangle_buffer<T: send, Tstart: send>(
fn entangle_buffer<T: Send, Tstart: Send>(
+buffer: ~Buffer<T>,
init: fn(*libc::c_void, x: &T) -> *Packet<Tstart>)
-> (SendPacketBuffered<Tstart, T>, RecvPacketBuffered<Tstart, T>)
@ -368,12 +368,12 @@ fn swap_state_rel(+dst: &mut State, src: State) -> State {
}
#[doc(hidden)]
unsafe fn get_buffer<T: send>(p: *PacketHeader) -> ~Buffer<T> {
unsafe fn get_buffer<T: Send>(p: *PacketHeader) -> ~Buffer<T> {
transmute((*p).buf_header())
}
// This could probably be done with SharedMutableState to avoid move_it!().
struct BufferResource<T: send> {
struct BufferResource<T: Send> {
buffer: ~Buffer<T>,
drop unsafe {
@ -393,7 +393,7 @@ struct BufferResource<T: send> {
}
}
fn BufferResource<T: send>(+b: ~Buffer<T>) -> BufferResource<T> {
fn BufferResource<T: Send>(+b: ~Buffer<T>) -> BufferResource<T> {
//let p = ptr::addr_of(*b);
//error!("take %?", p);
atomic_add_acq(&mut b.header.ref_count, 1);
@ -404,7 +404,7 @@ fn BufferResource<T: send>(+b: ~Buffer<T>) -> BufferResource<T> {
}
#[doc(hidden)]
fn send<T: send, Tbuffer: send>(+p: SendPacketBuffered<T, Tbuffer>,
fn send<T: Send, Tbuffer: Send>(+p: SendPacketBuffered<T, Tbuffer>,
+payload: T) -> bool {
let header = p.header();
let p_ = p.unwrap();
@ -448,7 +448,7 @@ fn send<T: send, Tbuffer: send>(+p: SendPacketBuffered<T, Tbuffer>,
Fails if the sender closes the connection.
*/
fn recv<T: send, Tbuffer: send>(+p: RecvPacketBuffered<T, Tbuffer>) -> T {
fn recv<T: Send, Tbuffer: Send>(+p: RecvPacketBuffered<T, Tbuffer>) -> T {
option::unwrap_expect(try_recv(p), "connection closed")
}
@ -458,7 +458,7 @@ Returns `none` if the sender has closed the connection without sending
a message, or `Some(T)` if a message was received.
*/
fn try_recv<T: send, Tbuffer: send>(+p: RecvPacketBuffered<T, Tbuffer>)
fn try_recv<T: Send, Tbuffer: Send>(+p: RecvPacketBuffered<T, Tbuffer>)
-> Option<T>
{
let p_ = p.unwrap();
@ -552,7 +552,7 @@ fn try_recv<T: send, Tbuffer: send>(+p: RecvPacketBuffered<T, Tbuffer>)
}
/// Returns true if messages are available.
pure fn peek<T: send, Tb: send>(p: &RecvPacketBuffered<T, Tb>) -> bool {
pure fn peek<T: Send, Tb: Send>(p: &RecvPacketBuffered<T, Tb>) -> bool {
match unsafe {(*p.header()).state} {
Empty => false,
Blocked => fail ~"peeking on blocked packet",
@ -560,14 +560,14 @@ pure fn peek<T: send, Tb: send>(p: &RecvPacketBuffered<T, Tb>) -> bool {
}
}
impl<T: send, Tb: send> RecvPacketBuffered<T, Tb> {
impl<T: Send, Tb: Send> RecvPacketBuffered<T, Tb> {
pure fn peek() -> bool {
peek(&self)
}
}
#[doc(hidden)]
fn sender_terminate<T: send>(p: *Packet<T>) {
fn sender_terminate<T: Send>(p: *Packet<T>) {
let p = unsafe { &*p };
match swap_state_rel(&mut p.header.state, Terminated) {
Empty => {
@ -596,7 +596,7 @@ fn sender_terminate<T: send>(p: *Packet<T>) {
}
#[doc(hidden)]
fn receiver_terminate<T: send>(p: *Packet<T>) {
fn receiver_terminate<T: Send>(p: *Packet<T>) {
let p = unsafe { &*p };
match swap_state_rel(&mut p.header.state, Terminated) {
Empty => {
@ -704,7 +704,7 @@ Sometimes messages will be available on both endpoints at once. In
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: RecvPacketBuffered<A, Ab>,
+b: RecvPacketBuffered<B, Bb>)
-> Either<(Option<A>, RecvPacketBuffered<B, Bb>),
@ -746,7 +746,7 @@ fn select2i<A: Selectable, B: Selectable>(a: &A, b: &B) -> Either<(), ()> {
list of the remaining endpoints.
*/
fn select<T: send, Tb: send>(+endpoints: ~[RecvPacketBuffered<T, Tb>])
fn select<T: Send, Tb: Send>(+endpoints: ~[RecvPacketBuffered<T, Tb>])
-> (uint, Option<T>, ~[RecvPacketBuffered<T, Tb>])
{
let ready = wait_many(endpoints.map(|p| p.header()));
@ -760,25 +760,25 @@ fn select<T: send, Tb: send>(+endpoints: ~[RecvPacketBuffered<T, Tb>])
message.
*/
type SendPacket<T: send> = SendPacketBuffered<T, Packet<T>>;
type SendPacket<T: Send> = SendPacketBuffered<T, Packet<T>>;
#[doc(hidden)]
fn SendPacket<T: send>(p: *Packet<T>) -> SendPacket<T> {
fn SendPacket<T: Send>(p: *Packet<T>) -> SendPacket<T> {
SendPacketBuffered(p)
}
// XXX remove me
#[cfg(stage0)]
#[allow(non_camel_case_types)]
type send_packet<T: send> = SendPacket<T>;
type send_packet<T: Send> = SendPacket<T>;
// XXX remove me
#[cfg(stage0)]
fn send_packet<T: send>(p: *packet<T>) -> SendPacket<T> {
fn send_packet<T: Send>(p: *packet<T>) -> SendPacket<T> {
SendPacket(p)
}
struct SendPacketBuffered<T: send, Tbuffer: send> {
struct SendPacketBuffered<T: Send, Tbuffer: Send> {
mut p: Option<*Packet<T>>,
mut buffer: Option<BufferResource<Tbuffer>>,
drop {
@ -821,7 +821,7 @@ struct SendPacketBuffered<T: send, Tbuffer: send> {
}
}
fn SendPacketBuffered<T: send, Tbuffer: send>(p: *Packet<T>)
fn SendPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
-> SendPacketBuffered<T, Tbuffer> {
//debug!("take send %?", p);
SendPacketBuffered {
@ -836,30 +836,30 @@ fn SendPacketBuffered<T: send, Tbuffer: send>(p: *Packet<T>)
// XXX remove me
#[cfg(stage0)]
#[allow(non_camel_case_types)]
type send_packet_buffered<T: send, Tbuffer: send> =
type send_packet_buffered<T: Send, Tbuffer: Send> =
SendPacketBuffered<T, Tbuffer>;
/// Represents the receive end of a pipe. It can receive exactly one
/// message.
type RecvPacket<T: send> = RecvPacketBuffered<T, Packet<T>>;
type RecvPacket<T: Send> = RecvPacketBuffered<T, Packet<T>>;
#[doc(hidden)]
fn RecvPacket<T: send>(p: *Packet<T>) -> RecvPacket<T> {
fn RecvPacket<T: Send>(p: *Packet<T>) -> RecvPacket<T> {
RecvPacketBuffered(p)
}
// XXX remove me
#[cfg(stage0)]
#[allow(non_camel_case_types)]
type recv_packet<T: send> = RecvPacket<T>;
type recv_packet<T: Send> = RecvPacket<T>;
// XXX remove me
#[cfg(stage0)]
fn recv_packet<T: send>(p: *packet<T>) -> RecvPacket<T> {
fn recv_packet<T: Send>(p: *packet<T>) -> RecvPacket<T> {
RecvPacket(p)
}
struct RecvPacketBuffered<T: send, Tbuffer: send> : Selectable {
struct RecvPacketBuffered<T: Send, Tbuffer: Send> : Selectable {
mut p: Option<*Packet<T>>,
mut buffer: Option<BufferResource<Tbuffer>>,
drop {
@ -902,7 +902,7 @@ struct RecvPacketBuffered<T: send, Tbuffer: send> : Selectable {
}
}
fn RecvPacketBuffered<T: send, Tbuffer: send>(p: *Packet<T>)
fn RecvPacketBuffered<T: Send, Tbuffer: Send>(p: *Packet<T>)
-> RecvPacketBuffered<T, Tbuffer> {
//debug!("take recv %?", p);
RecvPacketBuffered {
@ -917,11 +917,11 @@ fn RecvPacketBuffered<T: send, Tbuffer: send>(p: *Packet<T>)
// XXX remove me
#[cfg(stage0)]
#[allow(non_camel_case_types)]
type recv_packet_buffered<T: send, Tbuffer: send> =
type recv_packet_buffered<T: Send, Tbuffer: Send> =
RecvPacketBuffered<T, Tbuffer>;
#[doc(hidden)]
fn entangle<T: send>() -> (SendPacket<T>, RecvPacket<T>) {
fn entangle<T: Send>() -> (SendPacket<T>, RecvPacket<T>) {
let p = packet();
(SendPacket(p), RecvPacket(p))
}
@ -933,7 +933,7 @@ endpoint. The send endpoint is returned to the caller and the receive
endpoint is passed to the new task.
*/
fn spawn_service<T: send, Tb: send>(
fn spawn_service<T: Send, Tb: Send>(
init: extern fn() -> (SendPacketBuffered<T, Tb>,
RecvPacketBuffered<T, Tb>),
+service: fn~(+RecvPacketBuffered<T, Tb>))
@ -957,7 +957,7 @@ fn spawn_service<T: send, Tb: send>(
receive state.
*/
fn spawn_service_recv<T: send, Tb: send>(
fn spawn_service_recv<T: Send, Tb: Send>(
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
SendPacketBuffered<T, Tb>),
+service: fn~(+SendPacketBuffered<T, Tb>))
@ -980,13 +980,13 @@ fn spawn_service_recv<T: send, Tb: send>(
// Streams - Make pipes a little easier in general.
proto! streamp (
Open:send<T: send> {
Open:send<T: Send> {
data(T) -> Open<T>
}
)
/// A trait for things that can send multiple messages.
trait Channel<T: send> {
trait Channel<T: Send> {
// It'd be nice to call this send, but it'd conflict with the
// built in send kind.
@ -998,7 +998,7 @@ trait Channel<T: send> {
}
/// A trait for things that can receive multiple messages.
trait Recv<T: send> {
trait Recv<T: Send> {
/// Receives a message, or fails if the connection closes.
fn recv() -> T;
@ -1016,18 +1016,18 @@ trait Recv<T: send> {
}
#[doc(hidden)]
type Chan_<T:send> = { mut endp: Option<streamp::client::Open<T>> };
type Chan_<T:Send> = { mut endp: Option<streamp::client::Open<T>> };
/// An endpoint that can send many messages.
enum Chan<T:send> {
enum Chan<T:Send> {
Chan_(Chan_<T>)
}
#[doc(hidden)]
type Port_<T:send> = { mut endp: Option<streamp::server::Open<T>> };
type Port_<T:Send> = { mut endp: Option<streamp::server::Open<T>> };
/// An endpoint that can receive many messages.
enum Port<T:send> {
enum Port<T:Send> {
Port_(Port_<T>)
}
@ -1036,13 +1036,13 @@ enum Port<T:send> {
These allow sending or receiving an unlimited number of messages.
*/
fn stream<T:send>() -> (Chan<T>, Port<T>) {
fn stream<T:Send>() -> (Chan<T>, Port<T>) {
let (c, s) = streamp::init();
(Chan_({ mut endp: Some(c) }), Port_({ mut endp: Some(s) }))
}
impl<T: send> Chan<T>: Channel<T> {
impl<T: Send> Chan<T>: Channel<T> {
fn send(+x: T) {
let mut endp = None;
endp <-> self.endp;
@ -1063,7 +1063,7 @@ impl<T: send> Chan<T>: Channel<T> {
}
}
impl<T: send> Port<T>: Recv<T> {
impl<T: Send> Port<T>: Recv<T> {
fn recv() -> T {
let mut endp = None;
endp <-> self.endp;
@ -1097,7 +1097,7 @@ impl<T: send> Port<T>: Recv<T> {
}
/// Treat many ports as one.
struct PortSet<T: send> : Recv<T> {
struct PortSet<T: Send> : Recv<T> {
mut ports: ~[pipes::Port<T>],
fn add(+port: pipes::Port<T>) {
@ -1146,13 +1146,13 @@ struct PortSet<T: send> : Recv<T> {
}
}
fn PortSet<T: send>() -> PortSet<T>{
fn PortSet<T: Send>() -> PortSet<T>{
PortSet {
ports: ~[]
}
}
impl<T: send> Port<T>: Selectable {
impl<T: Send> Port<T>: Selectable {
pure fn header() -> *PacketHeader unchecked {
match self.endp {
Some(endp) => endp.header(),
@ -1162,9 +1162,9 @@ impl<T: send> Port<T>: Selectable {
}
/// A channel that can be shared between many senders.
type SharedChan<T: send> = unsafe::Exclusive<Chan<T>>;
type SharedChan<T: Send> = unsafe::Exclusive<Chan<T>>;
impl<T: send> SharedChan<T>: Channel<T> {
impl<T: Send> SharedChan<T>: Channel<T> {
fn send(+x: T) {
let mut xx = Some(x);
do self.with |chan| {
@ -1185,19 +1185,19 @@ impl<T: send> SharedChan<T>: Channel<T> {
}
/// Converts a `chan` into a `shared_chan`.
fn SharedChan<T:send>(+c: Chan<T>) -> SharedChan<T> {
fn SharedChan<T:Send>(+c: Chan<T>) -> SharedChan<T> {
unsafe::exclusive(c)
}
/// 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.
fn try_select() -> Either<Option<T>, Option<U>>;
/// Receive a message or fail if a connection closes.
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> {
fn select() -> Either<T, U> {
@ -1220,18 +1220,18 @@ impl<T: send, U: send, Left: Selectable Recv<T>, Right: Selectable Recv<U>>
}
proto! oneshot (
Oneshot:send<T:send> {
Oneshot:send<T:Send> {
send(T) -> !
}
)
/// The send end of a oneshot pipe.
type ChanOne<T: send> = oneshot::client::Oneshot<T>;
type ChanOne<T: Send> = oneshot::client::Oneshot<T>;
/// The receive end of a oneshot pipe.
type PortOne<T: send> = oneshot::server::Oneshot<T>;
type PortOne<T: Send> = oneshot::server::Oneshot<T>;
/// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair.
fn oneshot<T: send>() -> (ChanOne<T>, PortOne<T>) {
fn oneshot<T: Send>() -> (ChanOne<T>, PortOne<T>) {
oneshot::init()
}
@ -1239,13 +1239,13 @@ fn oneshot<T: send>() -> (ChanOne<T>, PortOne<T>) {
* Receive a message from a oneshot pipe, failing if the connection was
* closed.
*/
fn recv_one<T: send>(+port: PortOne<T>) -> T {
fn recv_one<T: Send>(+port: PortOne<T>) -> T {
let oneshot::send(message) = recv(port);
message
}
/// Receive a message from a oneshot pipe unless the connection was closed.
fn try_recv_one<T: send> (+port: PortOne<T>) -> Option<T> {
fn try_recv_one<T: Send> (+port: PortOne<T>) -> Option<T> {
let message = try_recv(port);
if message.is_none() { None }
@ -1256,7 +1256,7 @@ fn try_recv_one<T: send> (+port: PortOne<T>) -> Option<T> {
}
/// Send a message on a oneshot pipe, failing if the connection was closed.
fn send_one<T: send>(+chan: ChanOne<T>, +data: T) {
fn send_one<T: Send>(+chan: ChanOne<T>, +data: T) {
oneshot::client::send(chan, data);
}
@ -1264,7 +1264,7 @@ fn send_one<T: send>(+chan: ChanOne<T>, +data: T) {
* Send a message on a oneshot pipe, or return false if the connection was
* closed.
*/
fn try_send_one<T: send>(+chan: ChanOne<T>, +data: T)
fn try_send_one<T: Send>(+chan: ChanOne<T>, +data: T)
-> bool {
oneshot::client::try_send(chan, data).is_some()
}

View File

@ -27,7 +27,7 @@ type GlobalPtr = *libc::uintptr_t;
* or, if no channel exists creates and installs a new channel and sets up a
* new task to receive from it.
*/
unsafe fn chan_from_global_ptr<T: send>(
unsafe fn chan_from_global_ptr<T: Send>(
global: GlobalPtr,
task_fn: fn() -> task::TaskBuilder,
+f: fn~(comm::Port<T>)

View File

@ -165,12 +165,12 @@ impl Rng {
}
/// Choose an item randomly, failing if values is empty
fn choose<T:copy>(values: &[T]) -> T {
fn choose<T:Copy>(values: &[T]) -> T {
self.choose_option(values).get()
}
/// Choose Some(item) randomly, returning None if values is empty
fn choose_option<T:copy>(values: &[T]) -> Option<T> {
fn choose_option<T:Copy>(values: &[T]) -> Option<T> {
if values.is_empty() {
None
} else {
@ -182,7 +182,7 @@ impl Rng {
* Choose an item respecting the relative weights, failing if the sum of
* the weights is 0
*/
fn choose_weighted<T: copy>(v : &[Weighted<T>]) -> T {
fn choose_weighted<T: Copy>(v : &[Weighted<T>]) -> T {
self.choose_weighted_option(v).get()
}
@ -190,7 +190,7 @@ impl Rng {
* Choose Some(item) respecting the relative weights, returning none if
* the sum of the weights is 0
*/
fn choose_weighted_option<T:copy>(v: &[Weighted<T>]) -> Option<T> {
fn choose_weighted_option<T:Copy>(v: &[Weighted<T>]) -> Option<T> {
let mut total = 0u;
for v.each |item| {
total += item.weight;
@ -213,7 +213,7 @@ impl Rng {
* Return a vec containing copies of the items, in order, where
* the weight of the item determines how many copies there are
*/
fn weighted_vec<T:copy>(v: &[Weighted<T>]) -> ~[T] {
fn weighted_vec<T:Copy>(v: &[Weighted<T>]) -> ~[T] {
let mut r = ~[];
for v.each |item| {
for uint::range(0u, item.weight) |_i| {
@ -224,7 +224,7 @@ impl Rng {
}
/// Shuffle a vec
fn shuffle<T:copy>(values: &[T]) -> ~[T] {
fn shuffle<T:Copy>(values: &[T]) -> ~[T] {
let mut m = vec::from_slice(values);
self.shuffle_mut(m);
return m;

View File

@ -18,7 +18,7 @@ enum Result<T, U> {
*
* If the result is an error
*/
pure fn get<T: copy, U>(res: Result<T, U>) -> T {
pure fn get<T: Copy, U>(res: Result<T, U>) -> T {
match res {
Ok(t) => t,
Err(the_err) => unchecked {
@ -50,7 +50,7 @@ pure fn get_ref<T, U>(res: &a/Result<T, U>) -> &a/T {
*
* If the result is not an error
*/
pure fn get_err<T, U: copy>(res: Result<T, U>) -> U {
pure fn get_err<T, U: Copy>(res: Result<T, U>) -> U {
match res {
Err(u) => u,
Ok(_) => fail ~"get_err called on ok result"
@ -76,7 +76,7 @@ pure fn is_err<T, U>(res: Result<T, U>) -> bool {
* `ok` result variants are converted to `either::right` variants, `err`
* 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 {
Ok(res) => either::Right(res),
Err(fail_) => either::Left(fail_)
@ -97,7 +97,7 @@ pure fn to_either<T: copy, U: copy>(res: Result<U, T>) -> Either<T, U> {
* ok(parse_buf(buf))
* }
*/
fn chain<T, U: copy, V: copy>(res: Result<T, V>, op: fn(T) -> Result<U, V>)
fn chain<T, U: Copy, V: Copy>(res: Result<T, V>, op: fn(T) -> Result<U, V>)
-> Result<U, V> {
match res {
Ok(t) => op(t),
@ -113,7 +113,7 @@ fn chain<T, U: copy, V: copy>(res: Result<T, V>, op: fn(T) -> Result<U, V>)
* immediately returned. This function can be used to pass through a
* successful result while handling an error.
*/
fn chain_err<T: copy, U: copy, V: copy>(
fn chain_err<T: Copy, U: Copy, V: Copy>(
res: Result<T, V>,
op: fn(V) -> Result<T, U>)
-> Result<T, U> {
@ -173,7 +173,7 @@ fn iter_err<T, E>(res: Result<T, E>, f: fn(E)) {
* parse_buf(buf)
* }
*/
fn map<T, E: copy, U: copy>(res: Result<T, E>, op: fn(T) -> U)
fn map<T, E: Copy, U: Copy>(res: Result<T, E>, op: fn(T) -> U)
-> Result<U, E> {
match res {
Ok(t) => Ok(op(t)),
@ -189,7 +189,7 @@ fn map<T, E: copy, U: copy>(res: Result<T, E>, op: fn(T) -> U)
* is immediately returned. This function can be used to pass through a
* successful result while handling an error.
*/
fn map_err<T: copy, E, F: copy>(res: Result<T, E>, op: fn(E) -> F)
fn map_err<T: Copy, E, F: Copy>(res: Result<T, E>, op: fn(E) -> F)
-> Result<T, F> {
match res {
Ok(t) => Ok(t),
@ -217,10 +217,10 @@ impl<T, E> Result<T, E> {
}
}
impl<T: copy, E> Result<T, E> {
impl<T: Copy, E> Result<T, E> {
fn get() -> T { get(self) }
fn map_err<F:copy>(op: fn(E) -> F) -> Result<T,F> {
fn map_err<F:Copy>(op: fn(E) -> F) -> Result<T,F> {
match self {
Ok(t) => Ok(t),
Err(e) => Err(op(e))
@ -228,10 +228,10 @@ impl<T: copy, E> Result<T, E> {
}
}
impl<T, E: copy> Result<T, E> {
impl<T, E: Copy> Result<T, E> {
fn get_err() -> E { get_err(self) }
fn map<U:copy>(op: fn(T) -> U) -> Result<U,E> {
fn map<U:Copy>(op: fn(T) -> U) -> Result<U,E> {
match self {
Ok(t) => Ok(op(t)),
Err(e) => Err(e)
@ -239,12 +239,12 @@ impl<T, E: copy> Result<T, E> {
}
}
impl<T: copy, E: copy> Result<T, E> {
fn chain<U:copy>(op: fn(T) -> Result<U,E>) -> Result<U,E> {
impl<T: Copy, E: Copy> Result<T, E> {
fn chain<U:Copy>(op: fn(T) -> Result<U,E>) -> Result<U,E> {
chain(self, op)
}
fn chain_err<F:copy>(op: fn(E) -> Result<T,F>) -> Result<T,F> {
fn chain_err<F:Copy>(op: fn(E) -> Result<T,F>) -> Result<T,F> {
chain_err(self, op)
}
}
@ -266,7 +266,7 @@ impl<T: copy, E: copy> Result<T, E> {
* assert incd == ~[2u, 3u, 4u];
* }
*/
fn map_vec<T,U:copy,V:copy>(
fn map_vec<T,U:Copy,V:Copy>(
ts: &[T], op: fn(T) -> Result<V,U>) -> Result<~[V],U> {
let mut vs: ~[V] = ~[];
@ -280,7 +280,7 @@ fn map_vec<T,U:copy,V:copy>(
return Ok(vs);
}
fn map_opt<T,U:copy,V:copy>(
fn map_opt<T,U:Copy,V:Copy>(
o_t: Option<T>, op: fn(T) -> Result<V,U>) -> Result<Option<V>,U> {
match o_t {
@ -301,7 +301,7 @@ fn map_opt<T,U:copy,V:copy>(
* used in 'careful' code contexts where it is both appropriate and easy
* to accommodate an error like the vectors being of different lengths.
*/
fn map_vec2<S,T,U:copy,V:copy>(ss: &[S], ts: &[T],
fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
op: fn(S,T) -> Result<V,U>) -> Result<~[V],U> {
assert vec::same_length(ss, ts);
@ -324,7 +324,7 @@ fn map_vec2<S,T,U:copy,V:copy>(ss: &[S], ts: &[T],
* error. This could be implemented using `map2()` but it is more efficient
* on its own as no result vector is built.
*/
fn iter_vec2<S,T,U:copy>(ss: &[S], ts: &[T],
fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T],
op: fn(S,T) -> Result<(),U>) -> Result<(),U> {
assert vec::same_length(ss, ts);

View File

@ -8,7 +8,7 @@ use cmp::Eq;
use hash::Hash;
use to_bytes::IterBytes;
trait SendMap<K:Eq Hash, V: copy> {
trait SendMap<K:Eq Hash, V: Copy> {
// FIXME(#3148) ^^^^ once find_ref() works, we can drop V:copy
fn insert(&mut self, +k: K, +v: V) -> bool;
@ -315,7 +315,7 @@ mod linear {
}
}
impl<K:Hash IterBytes Eq, V: copy> LinearMap<K,V> {
impl<K:Hash IterBytes Eq, V: Copy> LinearMap<K,V> {
fn find(&const self, k: &K) -> Option<V> {
match self.bucket_for_key(self.buckets, k) {
FoundEntry(idx) => {
@ -342,17 +342,17 @@ mod linear {
}
impl<K: Hash IterBytes Eq copy, V: copy> LinearMap<K,V> {
impl<K: Hash IterBytes Eq Copy, V: Copy> LinearMap<K,V> {
fn each(&self, blk: fn(+K,+V) -> bool) {
self.each_ref(|k,v| blk(copy *k, copy *v));
}
}
impl<K: Hash IterBytes Eq copy, V> LinearMap<K,V> {
impl<K: Hash IterBytes Eq Copy, V> LinearMap<K,V> {
fn each_key(&self, blk: fn(+K) -> bool) {
self.each_key_ref(|k| blk(copy *k));
}
}
impl<K: Hash IterBytes Eq, V: copy> LinearMap<K,V> {
impl<K: Hash IterBytes Eq, V: Copy> LinearMap<K,V> {
fn each_value(&self, blk: fn(+V) -> bool) {
self.each_value_ref(|v| blk(copy *v));
}

View File

@ -380,7 +380,7 @@ impl TaskBuilder {
spawn_raw(x.opts, x.gen_body(f));
}
/// Runs a task, while transfering ownership of one argument to the child.
fn spawn_with<A: send>(+arg: A, +f: fn~(+A)) {
fn spawn_with<A: Send>(+arg: A, +f: fn~(+A)) {
let arg = ~mut Some(arg);
do self.spawn {
f(option::swap_unwrap(arg))
@ -398,7 +398,7 @@ impl TaskBuilder {
* otherwise be required to establish communication from the parent
* to the child.
*/
fn spawn_listener<A: send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
fn spawn_listener<A: Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
let setup_po = comm::Port();
let setup_ch = comm::Chan(setup_po);
do self.spawn {
@ -413,7 +413,7 @@ impl TaskBuilder {
/**
* Runs a new task, setting up communication in both directions
*/
fn spawn_conversation<A: send, B: send>
fn spawn_conversation<A: Send, B: Send>
(+f: fn~(comm::Port<A>, comm::Chan<B>))
-> (comm::Port<B>, comm::Chan<A>) {
let from_child = comm::Port();
@ -437,7 +437,7 @@ impl TaskBuilder {
* # Failure
* Fails if a future_result was already set for this task.
*/
fn try<T: send>(+f: fn~() -> T) -> Result<T,()> {
fn try<T: Send>(+f: fn~() -> T) -> Result<T,()> {
let po = comm::Port();
let ch = comm::Chan(po);
let mut result = None;
@ -504,7 +504,7 @@ fn spawn_supervised(+f: fn~()) {
task().supervised().spawn(f)
}
fn spawn_with<A:send>(+arg: A, +f: fn~(+A)) {
fn spawn_with<A:Send>(+arg: A, +f: fn~(+A)) {
/*!
* Runs a task, while transfering ownership of one argument to the
* child.
@ -518,7 +518,7 @@ fn spawn_with<A:send>(+arg: A, +f: fn~(+A)) {
task().spawn_with(arg, f)
}
fn spawn_listener<A:send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
fn spawn_listener<A:Send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
/*!
* Runs a new task while providing a channel from the parent to the child
*
@ -528,7 +528,7 @@ fn spawn_listener<A:send>(+f: fn~(comm::Port<A>)) -> comm::Chan<A> {
task().spawn_listener(f)
}
fn spawn_conversation<A: send, B: send>
fn spawn_conversation<A: Send, B: Send>
(+f: fn~(comm::Port<A>, comm::Chan<B>))
-> (comm::Port<B>, comm::Chan<A>) {
/*!
@ -557,7 +557,7 @@ fn spawn_sched(mode: SchedMode, +f: fn~()) {
task().sched_mode(mode).spawn(f)
}
fn try<T:send>(+f: fn~() -> T) -> Result<T,()> {
fn try<T:Send>(+f: fn~() -> T) -> Result<T,()> {
/*!
* Execute a function in another task and return either the return value
* of the function or result::err.
@ -1314,10 +1314,10 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
*
* These two cases aside, the interface is safe.
*/
type LocalDataKey<T: owned> = &fn(+@T);
type LocalDataKey<T: Owned> = &fn(+@T);
trait LocalData { }
impl<T: owned> @T: LocalData { }
impl<T: Owned> @T: LocalData { }
impl LocalData: Eq {
pure fn eq(&&other: LocalData) -> bool unsafe {
@ -1365,7 +1365,7 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
}
}
unsafe fn key_to_key_value<T: owned>(
unsafe fn key_to_key_value<T: Owned>(
key: LocalDataKey<T>) -> *libc::c_void {
// Keys are closures, which are (fnptr,envptr) pairs. Use fnptr.
@ -1375,7 +1375,7 @@ unsafe fn key_to_key_value<T: owned>(
}
// If returning Some(..), returns with @T with the map's reference. Careful!
unsafe fn local_data_lookup<T: owned>(
unsafe fn local_data_lookup<T: Owned>(
map: TaskLocalMap, key: LocalDataKey<T>)
-> Option<(uint, *libc::c_void)> {
@ -1393,7 +1393,7 @@ unsafe fn local_data_lookup<T: owned>(
}
}
unsafe fn local_get_helper<T: owned>(
unsafe fn local_get_helper<T: Owned>(
task: *rust_task, key: LocalDataKey<T>,
do_pop: bool) -> Option<@T> {
@ -1414,21 +1414,21 @@ unsafe fn local_get_helper<T: owned>(
}
}
unsafe fn local_pop<T: owned>(
unsafe fn local_pop<T: Owned>(
task: *rust_task,
key: LocalDataKey<T>) -> Option<@T> {
local_get_helper(task, key, true)
}
unsafe fn local_get<T: owned>(
unsafe fn local_get<T: Owned>(
task: *rust_task,
key: LocalDataKey<T>) -> Option<@T> {
local_get_helper(task, key, false)
}
unsafe fn local_set<T: owned>(
unsafe fn local_set<T: Owned>(
task: *rust_task, key: LocalDataKey<T>, +data: @T) {
let map = get_task_local_map(task);
@ -1460,7 +1460,7 @@ unsafe fn local_set<T: owned>(
}
}
unsafe fn local_modify<T: owned>(
unsafe fn local_modify<T: Owned>(
task: *rust_task, key: LocalDataKey<T>,
modify_fn: fn(Option<@T>) -> Option<@T>) {
@ -1476,7 +1476,7 @@ unsafe fn local_modify<T: owned>(
* Remove a task-local data value from the table, returning the
* reference that was originally created to insert it.
*/
unsafe fn local_data_pop<T: owned>(
unsafe fn local_data_pop<T: Owned>(
key: LocalDataKey<T>) -> Option<@T> {
local_pop(rustrt::rust_get_task(), key)
@ -1485,7 +1485,7 @@ unsafe fn local_data_pop<T: owned>(
* Retrieve a task-local data value. It will also be kept alive in the
* table until explicitly removed.
*/
unsafe fn local_data_get<T: owned>(
unsafe fn local_data_get<T: Owned>(
key: LocalDataKey<T>) -> Option<@T> {
local_get(rustrt::rust_get_task(), key)
@ -1494,7 +1494,7 @@ unsafe fn local_data_get<T: owned>(
* Store a value in task-local data. If this key already has a value,
* that value is overwritten (and its destructor is run).
*/
unsafe fn local_data_set<T: owned>(
unsafe fn local_data_set<T: Owned>(
key: LocalDataKey<T>, +data: @T) {
local_set(rustrt::rust_get_task(), key, data)
@ -1503,7 +1503,7 @@ unsafe fn local_data_set<T: owned>(
* Modify a task-local data value. If the function returns 'none', the
* data is removed (and its reference dropped).
*/
unsafe fn local_data_modify<T: owned>(
unsafe fn local_data_modify<T: Owned>(
key: LocalDataKey<T>,
modify_fn: fn(Option<@T>) -> Option<@T>) {

View File

@ -50,13 +50,13 @@ impl &str: ToStr {
fn to_str() -> ~str { str::from_slice(self) }
}
impl<A: ToStr copy, B: ToStr copy> (A, B): ToStr {
impl<A: ToStr Copy, B: ToStr Copy> (A, B): ToStr {
fn to_str() -> ~str {
let (a, b) = self;
~"(" + a.to_str() + ~", " + b.to_str() + ~")"
}
}
impl<A: ToStr copy, B: ToStr copy, C: ToStr copy> (A, B, C): ToStr {
impl<A: ToStr Copy, B: ToStr Copy, C: ToStr Copy> (A, B, C): ToStr {
fn to_str() -> ~str {
let (a, b, c) = self;
~"(" + a.to_str() + ~", " + b.to_str() + ~", " + c.to_str() + ~")"

View File

@ -12,7 +12,7 @@ trait TupleOps<T,U> {
pure fn swap() -> (U, T);
}
impl<T: copy, U: copy> (T, U): TupleOps<T,U> {
impl<T: Copy, U: Copy> (T, U): TupleOps<T,U> {
/// Return the first element of self
pure fn first() -> T {
@ -39,7 +39,7 @@ trait ExtendedTupleOps<A,B> {
fn map<C>(f: fn(A, B) -> C) -> ~[C];
}
impl<A: copy, B: copy> (&[A], &[B]): ExtendedTupleOps<A,B> {
impl<A: Copy, B: Copy> (&[A], &[B]): ExtendedTupleOps<A,B> {
fn zip() -> ~[(A, B)] {
let (a, b) = self;
@ -52,7 +52,7 @@ impl<A: copy, B: copy> (&[A], &[B]): ExtendedTupleOps<A,B> {
}
}
impl<A: copy, B: copy> (~[A], ~[B]): ExtendedTupleOps<A,B> {
impl<A: Copy, B: Copy> (~[A], ~[B]): ExtendedTupleOps<A,B> {
fn zip() -> ~[(A, B)] {
// XXX: Bad copy

View File

@ -137,7 +137,7 @@ fn ArcDestruct<T>(data: *libc::c_void) -> ArcDestruct<T> {
}
}
unsafe fn unwrap_shared_mutable_state<T: send>(+rc: SharedMutableState<T>)
unsafe fn unwrap_shared_mutable_state<T: Send>(+rc: SharedMutableState<T>)
-> T {
struct DeathThroes<T> {
mut ptr: Option<~ArcData<T>>,
@ -207,9 +207,9 @@ unsafe fn unwrap_shared_mutable_state<T: send>(+rc: SharedMutableState<T>)
* Data races between tasks can result in crashes and, with sufficient
* cleverness, arbitrary type coercion.
*/
type SharedMutableState<T: send> = ArcDestruct<T>;
type SharedMutableState<T: Send> = ArcDestruct<T>;
unsafe fn shared_mutable_state<T: send>(+data: T) -> SharedMutableState<T> {
unsafe fn shared_mutable_state<T: Send>(+data: T) -> SharedMutableState<T> {
let data = ~ArcData { count: 1, unwrapper: 0, data: Some(data) };
unsafe {
let ptr = unsafe::transmute(data);
@ -218,7 +218,7 @@ unsafe fn shared_mutable_state<T: send>(+data: T) -> SharedMutableState<T> {
}
#[inline(always)]
unsafe fn get_shared_mutable_state<T: send>(rc: &a/SharedMutableState<T>)
unsafe fn get_shared_mutable_state<T: Send>(rc: &a/SharedMutableState<T>)
-> &a/mut T {
unsafe {
let ptr: ~ArcData<T> = unsafe::reinterpret_cast(&(*rc).data);
@ -230,7 +230,7 @@ unsafe fn get_shared_mutable_state<T: send>(rc: &a/SharedMutableState<T>)
}
}
#[inline(always)]
unsafe fn get_shared_immutable_state<T: send>(rc: &a/SharedMutableState<T>)
unsafe fn get_shared_immutable_state<T: Send>(rc: &a/SharedMutableState<T>)
-> &a/T {
unsafe {
let ptr: ~ArcData<T> = unsafe::reinterpret_cast(&(*rc).data);
@ -242,7 +242,7 @@ unsafe fn get_shared_immutable_state<T: send>(rc: &a/SharedMutableState<T>)
}
}
unsafe fn clone_shared_mutable_state<T: send>(rc: &SharedMutableState<T>)
unsafe fn clone_shared_mutable_state<T: Send>(rc: &SharedMutableState<T>)
-> SharedMutableState<T> {
unsafe {
let ptr: ~ArcData<T> = unsafe::reinterpret_cast(&(*rc).data);
@ -312,20 +312,20 @@ impl LittleLock {
}
}
struct ExData<T: send> { lock: LittleLock, mut failed: bool, mut data: T, }
struct ExData<T: Send> { lock: LittleLock, mut failed: bool, mut data: T, }
/**
* An arc over mutable data that is protected by a lock. For library use only.
*/
struct Exclusive<T: send> { x: SharedMutableState<ExData<T>> }
struct Exclusive<T: Send> { x: SharedMutableState<ExData<T>> }
fn exclusive<T:send >(+user_data: T) -> Exclusive<T> {
fn exclusive<T:Send >(+user_data: T) -> Exclusive<T> {
let data = ExData {
lock: LittleLock(), mut failed: false, mut data: user_data
};
Exclusive { x: unsafe { shared_mutable_state(data) } }
}
impl<T: send> Exclusive<T> {
impl<T: Send> Exclusive<T> {
// Duplicate an exclusive ARC, as std::arc::clone.
fn clone() -> Exclusive<T> {
Exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } }
@ -353,7 +353,7 @@ impl<T: send> Exclusive<T> {
}
// FIXME(#2585) make this a by-move method on the exclusive
fn unwrap_exclusive<T: send>(+arc: Exclusive<T>) -> T {
fn unwrap_exclusive<T: Send>(+arc: Exclusive<T>) -> T {
let Exclusive { x: x } = arc;
let inner = unsafe { unwrap_shared_mutable_state(x) };
let ExData { data: data, _ } = inner;

View File

@ -17,7 +17,7 @@ pure fn ignore<T>(+_x: T) { }
/// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the
/// original value of `*ptr`.
#[inline(always)]
fn with<T: copy, R>(
fn with<T: Copy, R>(
ptr: &mut T,
+new_value: T,
op: &fn() -> R) -> R

View File

@ -199,7 +199,7 @@ pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] {
* Creates an immutable vector of size `n_elts` and initializes the elements
* to the value `t`.
*/
pure fn from_elem<T: copy>(n_elts: uint, t: T) -> ~[T] {
pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> ~[T] {
let mut v = ~[];
unchecked{reserve(v, n_elts)}
let mut i: uint = 0u;
@ -211,7 +211,7 @@ pure fn from_elem<T: copy>(n_elts: uint, t: T) -> ~[T] {
}
/// Creates a new unique vector with the same contents as the slice
pure fn from_slice<T: copy>(t: &[T]) -> ~[T] {
pure fn from_slice<T: Copy>(t: &[T]) -> ~[T] {
from_fn(t.len(), |i| t[i])
}
@ -281,10 +281,10 @@ pure fn from_mut<T>(+v: ~[mut T]) -> ~[T] {
// Accessors
/// Returns the first element of a vector
pure fn head<T: copy>(v: &[const T]) -> T { v[0] }
pure fn head<T: Copy>(v: &[const T]) -> T { v[0] }
/// Returns a vector containing all but the first element of a slice
pure fn tail<T: copy>(v: &[const T]) -> ~[T] {
pure fn tail<T: Copy>(v: &[const T]) -> ~[T] {
return slice(v, 1u, len(v));
}
@ -292,18 +292,18 @@ pure fn tail<T: copy>(v: &[const T]) -> ~[T] {
* Returns a vector containing all but the first `n` \
* elements of a slice
*/
pure fn tailn<T: copy>(v: &[const T], n: uint) -> ~[T] {
pure fn tailn<T: Copy>(v: &[const T], n: uint) -> ~[T] {
slice(v, n, len(v))
}
/// Returns a vector containing all but the last element of a slice
pure fn init<T: copy>(v: &[const T]) -> ~[T] {
pure fn init<T: Copy>(v: &[const T]) -> ~[T] {
assert len(v) != 0u;
slice(v, 0u, len(v) - 1u)
}
/// Returns the last element of the slice `v`, failing if the slice is empty.
pure fn last<T: copy>(v: &[const T]) -> T {
pure fn last<T: Copy>(v: &[const T]) -> T {
if len(v) == 0u { fail ~"last_unsafe: empty vector" }
v[len(v) - 1u]
}
@ -312,13 +312,13 @@ pure fn last<T: copy>(v: &[const T]) -> T {
* Returns `Some(x)` where `x` is the last element of the slice `v`,
* or `none` if the vector is empty.
*/
pure fn last_opt<T: copy>(v: &[const T]) -> Option<T> {
pure fn last_opt<T: Copy>(v: &[const T]) -> Option<T> {
if len(v) == 0u { return None; }
Some(v[len(v) - 1u])
}
/// Returns a copy of the elements from [`start`..`end`) from `v`.
pure fn slice<T: copy>(v: &[const T], start: uint, end: uint) -> ~[T] {
pure fn slice<T: Copy>(v: &[const T], start: uint, end: uint) -> ~[T] {
assert (start <= end);
assert (end <= len(v));
let mut result = ~[];
@ -365,7 +365,7 @@ pure fn const_view<T>(v: &[const T], start: uint, end: uint) -> &[const T] {
}
/// Split the vector `v` by applying each element against the predicate `f`.
fn split<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] {
fn split<T: Copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] {
let ln = len(v);
if (ln == 0u) { return ~[] }
@ -388,7 +388,7 @@ fn split<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] {
* Split the vector `v` by applying each element against the predicate `f` up
* to `n` times.
*/
fn splitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] {
fn splitn<T: Copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] {
let ln = len(v);
if (ln == 0u) { return ~[] }
@ -414,7 +414,7 @@ fn splitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] {
* Reverse split the vector `v` by applying each element against the predicate
* `f`.
*/
fn rsplit<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] {
fn rsplit<T: Copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] {
let ln = len(v);
if (ln == 0u) { return ~[] }
@ -438,7 +438,7 @@ fn rsplit<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] {
* Reverse split the vector `v` by applying each element against the predicate
* `f` up to `n times.
*/
fn rsplitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] {
fn rsplitn<T: Copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] {
let ln = len(v);
if (ln == 0u) { return ~[] }
@ -589,7 +589,7 @@ fn push_slow<T>(&v: ~[const T], +initval: T) {
}
#[inline(always)]
fn push_all<T: copy>(&v: ~[const T], rhs: &[const T]) {
fn push_all<T: Copy>(&v: ~[const T], rhs: &[const T]) {
reserve(v, v.len() + rhs.len());
for uint::range(0u, rhs.len()) |i| {
@ -627,7 +627,7 @@ fn truncate<T>(&v: ~[const T], newlen: uint) {
// Appending
#[inline(always)]
pure fn append<T: copy>(+lhs: ~[T], rhs: &[const T]) -> ~[T] {
pure fn append<T: Copy>(+lhs: ~[T], rhs: &[const T]) -> ~[T] {
let mut v <- lhs;
unchecked {
push_all(v, rhs);
@ -643,7 +643,7 @@ pure fn append_one<T>(+lhs: ~[T], +x: T) -> ~[T] {
}
#[inline(always)]
pure fn append_mut<T: copy>(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] {
pure fn append_mut<T: Copy>(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] {
let mut v = ~[mut];
let mut i = 0u;
while i < lhs.len() {
@ -671,7 +671,7 @@ pure fn append_mut<T: copy>(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] {
* * n - The number of elements to add
* * initval - The value for the new elements
*/
fn grow<T: copy>(&v: ~[const T], n: uint, initval: T) {
fn grow<T: Copy>(&v: ~[const T], n: uint, initval: T) {
reserve_at_least(v, len(v) + n);
let mut i: uint = 0u;
@ -705,7 +705,7 @@ fn grow_fn<T>(&v: ~[const T], n: uint, op: iter::InitOp<T>) {
* of the vector, expands the vector by replicating `initval` to fill the
* intervening space.
*/
fn grow_set<T: copy>(&v: ~[mut T], index: uint, initval: T, val: T) {
fn grow_set<T: Copy>(&v: ~[mut T], index: uint, initval: T, val: T) {
if index >= len(v) { grow(v, index - len(v) + 1u, initval); }
v[index] = val;
}
@ -747,7 +747,7 @@ pure fn flat_map<T, U>(v: &[T], f: fn(T) -> ~[U]) -> ~[U] {
}
/// Apply a function to each pair of elements and return the results
pure fn map2<T: copy, U: copy, V>(v0: &[T], v1: &[U],
pure fn map2<T: Copy, U: Copy, V>(v0: &[T], v1: &[U],
f: fn(T, U) -> V) -> ~[V] {
let v0_len = len(v0);
if v0_len != len(v1) { fail; }
@ -766,7 +766,7 @@ pure fn map2<T: copy, U: copy, V>(v0: &[T], v1: &[U],
* If function `f` returns `none` then that element is excluded from
* the resulting vector.
*/
pure fn filter_map<T, U: copy>(v: &[T], f: fn(T) -> Option<U>)
pure fn filter_map<T, U: Copy>(v: &[T], f: fn(T) -> Option<U>)
-> ~[U] {
let mut result = ~[];
for each(v) |elem| {
@ -785,7 +785,7 @@ pure fn filter_map<T, U: copy>(v: &[T], f: fn(T) -> Option<U>)
* Apply function `f` to each element of `v` and return a vector containing
* only those elements for which `f` returned true.
*/
pure fn filter<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[T] {
pure fn filter<T: Copy>(v: &[T], f: fn(T) -> bool) -> ~[T] {
let mut result = ~[];
for each(v) |elem| {
if f(elem) { unsafe { push(result, elem); } }
@ -798,14 +798,14 @@ pure fn filter<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[T] {
*
* Flattens a vector of vectors of T into a single vector of T.
*/
pure fn concat<T: copy>(v: &[~[T]]) -> ~[T] {
pure fn concat<T: Copy>(v: &[~[T]]) -> ~[T] {
let mut r = ~[];
for each(v) |inner| { unsafe { push_all(r, inner); } }
return r;
}
/// Concatenate a vector of vectors, placing a given separator between each
pure fn connect<T: copy>(v: &[~[T]], sep: T) -> ~[T] {
pure fn connect<T: Copy>(v: &[~[T]], sep: T) -> ~[T] {
let mut r: ~[T] = ~[];
let mut first = true;
for each(v) |inner| {
@ -816,7 +816,7 @@ pure fn connect<T: copy>(v: &[~[T]], sep: T) -> ~[T] {
}
/// Reduce a vector from left to right
pure fn foldl<T: copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T {
pure fn foldl<T: Copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T {
let mut accum = z;
do iter(v) |elt| {
accum = p(accum, elt);
@ -825,7 +825,7 @@ pure fn foldl<T: copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T {
}
/// Reduce a vector from right to left
pure fn foldr<T, U: copy>(v: &[T], z: U, p: fn(T, U) -> U) -> U {
pure fn foldr<T, U: Copy>(v: &[T], z: U, p: fn(T, U) -> U) -> U {
let mut accum = z;
do riter(v) |elt| {
accum = p(elt, accum);
@ -914,7 +914,7 @@ pure fn count<T: Eq>(v: &[T], x: T) -> uint {
* When function `f` returns true then an option containing the element
* is returned. If `f` matches no elements then none is returned.
*/
pure fn find<T: copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
pure fn find<T: Copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
find_between(v, 0u, len(v), f)
}
@ -925,7 +925,7 @@ pure fn find<T: copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
* [`start`, `end`). When function `f` returns true then an option containing
* the element is returned. If `f` matches no elements then none is returned.
*/
pure fn find_between<T: copy>(v: &[T], start: uint, end: uint,
pure fn find_between<T: Copy>(v: &[T], start: uint, end: uint,
f: fn(T) -> bool) -> Option<T> {
option::map(position_between(v, start, end, f), |i| v[i])
}
@ -937,7 +937,7 @@ pure fn find_between<T: copy>(v: &[T], start: uint, end: uint,
* `f` returns true then an option containing the element is returned. If `f`
* matches no elements then none is returned.
*/
pure fn rfind<T: copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
pure fn rfind<T: Copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
rfind_between(v, 0u, len(v), f)
}
@ -948,7 +948,7 @@ pure fn rfind<T: copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
* [`start`, `end`). When function `f` returns true then an option containing
* the element is returned. If `f` matches no elements then none is returned.
*/
pure fn rfind_between<T: copy>(v: &[T], start: uint, end: uint,
pure fn rfind_between<T: Copy>(v: &[T], start: uint, end: uint,
f: fn(T) -> bool) -> Option<T> {
option::map(rposition_between(v, start, end, f), |i| v[i])
}
@ -1028,7 +1028,7 @@ pure fn rposition_between<T>(v: &[T], start: uint, end: uint,
/**
* Convert a vector of pairs into a pair of vectors, by reference. As unzip().
*/
pure fn unzip_slice<T: copy, U: copy>(v: &[(T, U)]) -> (~[T], ~[U]) {
pure fn unzip_slice<T: Copy, U: Copy>(v: &[(T, U)]) -> (~[T], ~[U]) {
let mut as = ~[], bs = ~[];
for each(v) |p| {
let (a, b) = p;
@ -1063,7 +1063,7 @@ pure fn unzip<T,U>(+v: ~[(T, U)]) -> (~[T], ~[U]) {
/**
* Convert two vectors to a vector of pairs, by reference. As zip().
*/
pure fn zip_slice<T: copy, U: copy>(v: &[const T], u: &[const U])
pure fn zip_slice<T: Copy, U: Copy>(v: &[const T], u: &[const U])
-> ~[(T, U)] {
let mut zipped = ~[];
let sz = len(v);
@ -1113,7 +1113,7 @@ fn reverse<T>(v: ~[mut T]) {
/// Returns a vector with the order of elements reversed
pure fn reversed<T: copy>(v: &[const T]) -> ~[T] {
pure fn reversed<T: Copy>(v: &[const T]) -> ~[T] {
let mut rs: ~[T] = ~[];
let mut i = len::<T>(v);
if i == 0u { return rs; } else { i -= 1u; }
@ -1317,7 +1317,7 @@ pure fn riteri<T>(v: &[T], f: fn(uint, T)) {
* The total number of permutations produced is `len(v)!`. If `v` contains
* repeated elements, then some permutations are repeated.
*/
pure fn permute<T: copy>(v: &[const T], put: fn(~[T])) {
pure fn permute<T: Copy>(v: &[const T], put: fn(~[T])) {
let ln = len(v);
if ln == 0u {
put(~[]);
@ -1337,7 +1337,7 @@ pure fn permute<T: copy>(v: &[const T], put: fn(~[T])) {
}
}
pure fn windowed<TT: copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] {
pure fn windowed<TT: Copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] {
let mut ww = ~[];
assert 1u <= nn;
vec::iteri (xx, |ii, _x| {
@ -1480,14 +1480,14 @@ impl<T: Ord> @[T]: Ord {
}
#[cfg(notest)]
impl<T: copy> ~[T]: Add<&[const T],~[T]> {
impl<T: Copy> ~[T]: Add<&[const T],~[T]> {
#[inline(always)]
pure fn add(rhs: &[const T]) -> ~[T] {
append(copy self, rhs)
}
}
impl<T: copy> ~[mut T]: Add<&[const T],~[mut T]> {
impl<T: Copy> ~[mut T]: Add<&[const T],~[mut T]> {
#[inline(always)]
pure fn add(rhs: &[const T]) -> ~[mut T] {
append_mut(self, rhs)
@ -1522,7 +1522,7 @@ trait CopyableVector<T> {
}
/// Extension methods for vectors
impl<T: copy> &[const T]: CopyableVector<T> {
impl<T: Copy> &[const T]: CopyableVector<T> {
/// Returns the first element of a vector
#[inline]
pure fn head() -> T { head(self) }
@ -1541,7 +1541,7 @@ impl<T: copy> &[const T]: CopyableVector<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 iteri(f: fn(uint, T));
pure fn riter(f: fn(T));
@ -1551,7 +1551,7 @@ trait ImmutableVector<T> {
fn map_r<U>(f: fn(x: &T) -> U) -> ~[U];
pure fn alli(f: fn(uint, T) -> bool) -> bool;
pure fn flat_map<U>(f: fn(T) -> ~[U]) -> ~[U];
pure fn filter_map<U: copy>(f: fn(T) -> Option<U>) -> ~[U];
pure fn filter_map<U: Copy>(f: fn(T) -> Option<U>) -> ~[U];
}
trait ImmutableEqVector<T: Eq> {
@ -1565,7 +1565,7 @@ trait ImmutableEqVector<T: Eq> {
impl<T> &[T]: ImmutableVector<T> {
/// Reduce a vector from right to left
#[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) }
/**
* Iterates over a vector
*
@ -1641,7 +1641,7 @@ impl<T> &[T]: ImmutableVector<T> {
* the resulting vector.
*/
#[inline]
pure fn filter_map<U: copy>(f: fn(T) -> Option<U>) -> ~[U] {
pure fn filter_map<U: Copy>(f: fn(T) -> Option<U>) -> ~[U] {
filter_map(self, f)
}
}
@ -1679,7 +1679,7 @@ trait ImmutableCopyableVector<T> {
}
/// Extension methods for vectors
impl<T: copy> &[T]: ImmutableCopyableVector<T> {
impl<T: Copy> &[T]: ImmutableCopyableVector<T> {
/**
* Construct a new vector from the elements of a vector for which some
* predicate holds.
@ -1785,7 +1785,7 @@ mod unsafe {
* Unchecked vector indexing.
*/
#[inline(always)]
unsafe fn get<T: copy>(v: &[const T], i: uint) -> T {
unsafe fn get<T: Copy>(v: &[const T], i: uint) -> T {
as_buf(v, |p, _len| *ptr::offset(p, i))
}
@ -1938,7 +1938,7 @@ impl<A: Eq> &[A]: iter::EqIter<A> {
}
}
impl<A: copy> &[A]: iter::CopyableIter<A> {
impl<A: Copy> &[A]: iter::CopyableIter<A> {
pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred)
}
@ -1955,7 +1955,7 @@ impl<A: copy> &[A]: iter::CopyableIter<A> {
pure fn find(p: fn(A) -> bool) -> Option<A> { iter::find(self, p) }
}
impl<A: copy Ord> &[A]: iter::CopyableOrderedIter<A> {
impl<A: Copy Ord> &[A]: iter::CopyableOrderedIter<A> {
pure fn min() -> A { iter::min(self) }
pure fn max() -> A { iter::max(self) }
}

View File

@ -69,10 +69,10 @@ impl &Condvar {
****************************************************************************/
/// An atomically reference counted wrapper for shared immutable state.
struct ARC<T: const send> { x: SharedMutableState<T> }
struct ARC<T: Const Send> { x: SharedMutableState<T> }
/// Create an atomically reference counted wrapper.
fn ARC<T: const send>(+data: T) -> ARC<T> {
fn ARC<T: Const Send>(+data: T) -> ARC<T> {
ARC { x: unsafe { shared_mutable_state(data) } }
}
@ -80,7 +80,7 @@ fn ARC<T: const send>(+data: T) -> ARC<T> {
* Access the underlying data in an atomically reference counted
* wrapper.
*/
fn get<T: const send>(rc: &a/ARC<T>) -> &a/T {
fn get<T: Const Send>(rc: &a/ARC<T>) -> &a/T {
unsafe { get_shared_immutable_state(&rc.x) }
}
@ -91,7 +91,7 @@ fn get<T: const send>(rc: &a/ARC<T>) -> &a/T {
* object. However, one of the `arc` objects can be sent to another task,
* allowing them to share the underlying data.
*/
fn clone<T: const send>(rc: &ARC<T>) -> ARC<T> {
fn clone<T: Const Send>(rc: &ARC<T>) -> ARC<T> {
ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } }
}
@ -104,7 +104,7 @@ fn clone<T: const send>(rc: &ARC<T>) -> ARC<T> {
* unwrap from a task that holds another reference to the same ARC; it is
* guaranteed to deadlock.
*/
fn unwrap<T: const send>(+rc: ARC<T>) -> T {
fn unwrap<T: Const Send>(+rc: ARC<T>) -> T {
let ARC { x: x } = rc;
unsafe { unwrap_shared_mutable_state(x) }
}
@ -114,19 +114,19 @@ fn unwrap<T: const send>(+rc: ARC<T>) -> T {
****************************************************************************/
#[doc(hidden)]
struct MutexARCInner<T: send> { lock: Mutex, failed: bool, data: T }
struct MutexARCInner<T: Send> { lock: Mutex, failed: bool, data: T }
/// An ARC with mutable data protected by a blocking mutex.
struct MutexARC<T: send> { x: SharedMutableState<MutexARCInner<T>> }
struct MutexARC<T: Send> { x: SharedMutableState<MutexARCInner<T>> }
/// Create a mutex-protected ARC with the supplied data.
fn MutexARC<T: send>(+user_data: T) -> MutexARC<T> {
fn MutexARC<T: Send>(+user_data: T) -> MutexARC<T> {
mutex_arc_with_condvars(user_data, 1)
}
/**
* Create a mutex-protected ARC with the supplied data and a specified number
* of condvars (as sync::mutex_with_condvars).
*/
fn mutex_arc_with_condvars<T: send>(+user_data: T,
fn mutex_arc_with_condvars<T: Send>(+user_data: T,
num_condvars: uint) -> MutexARC<T> {
let data =
MutexARCInner { lock: mutex_with_condvars(num_condvars),
@ -134,7 +134,7 @@ fn mutex_arc_with_condvars<T: send>(+user_data: T,
MutexARC { x: unsafe { shared_mutable_state(data) } }
}
impl<T: send> &MutexARC<T> {
impl<T: Send> &MutexARC<T> {
/// Duplicate a mutex-protected ARC, as arc::clone.
fn clone() -> MutexARC<T> {
// NB: Cloning the underlying mutex is not necessary. Its reference
@ -197,7 +197,7 @@ impl<T: send> &MutexARC<T> {
* Will additionally fail if another task has failed while accessing the arc.
*/
// FIXME(#2585) make this a by-move method on the arc
fn unwrap_mutex_arc<T: send>(+arc: MutexARC<T>) -> T {
fn unwrap_mutex_arc<T: Send>(+arc: MutexARC<T>) -> T {
let MutexARC { x: x } = arc;
let inner = unsafe { unwrap_shared_mutable_state(x) };
let MutexARCInner { failed: failed, data: data, _ } = inner;
@ -240,27 +240,27 @@ fn PoisonOnFail(failed: &r/mut bool) -> PoisonOnFail/&r {
****************************************************************************/
#[doc(hidden)]
struct RWARCInner<T: const send> { lock: RWlock, failed: bool, data: T }
struct RWARCInner<T: Const Send> { lock: RWlock, failed: bool, data: T }
/**
* A dual-mode ARC protected by a reader-writer lock. The data can be accessed
* mutably or immutably, and immutably-accessing tasks may run concurrently.
*
* Unlike mutex_arcs, rw_arcs are safe, because they cannot be nested.
*/
struct RWARC<T: const send> {
struct RWARC<T: Const Send> {
x: SharedMutableState<RWARCInner<T>>,
mut cant_nest: ()
}
/// Create a reader/writer ARC with the supplied data.
fn RWARC<T: const send>(+user_data: T) -> RWARC<T> {
fn RWARC<T: Const Send>(+user_data: T) -> RWARC<T> {
rw_arc_with_condvars(user_data, 1)
}
/**
* Create a reader/writer ARC with the supplied data and a specified number
* of condvars (as sync::rwlock_with_condvars).
*/
fn rw_arc_with_condvars<T: const send>(+user_data: T,
fn rw_arc_with_condvars<T: Const Send>(+user_data: T,
num_condvars: uint) -> RWARC<T> {
let data =
RWARCInner { lock: rwlock_with_condvars(num_condvars),
@ -268,7 +268,7 @@ fn rw_arc_with_condvars<T: const send>(+user_data: T,
RWARC { x: unsafe { shared_mutable_state(data) }, cant_nest: () }
}
impl<T: const send> &RWARC<T> {
impl<T: Const Send> &RWARC<T> {
/// Duplicate a rwlock-protected ARC, as arc::clone.
fn clone() -> RWARC<T> {
RWARC { x: unsafe { clone_shared_mutable_state(&self.x) },
@ -375,7 +375,7 @@ impl<T: const send> &RWARC<T> {
* in write mode.
*/
// FIXME(#2585) make this a by-move method on the arc
fn unwrap_rw_arc<T: const send>(+arc: RWARC<T>) -> T {
fn unwrap_rw_arc<T: Const Send>(+arc: RWARC<T>) -> T {
let RWARC { x: x, _ } = arc;
let inner = unsafe { unwrap_shared_mutable_state(x) };
let RWARCInner { failed: failed, data: data, _ } = inner;
@ -389,19 +389,19 @@ fn unwrap_rw_arc<T: const send>(+arc: RWARC<T>) -> T {
// lock it. This wraps the unsafety, with the justification that the 'lock'
// field is never overwritten; only 'failed' and 'data'.
#[doc(hidden)]
fn borrow_rwlock<T: const send>(state: &r/mut RWARCInner<T>) -> &r/RWlock {
fn borrow_rwlock<T: Const Send>(state: &r/mut RWARCInner<T>) -> &r/RWlock {
unsafe { unsafe::transmute_immut(&mut state.lock) }
}
// FIXME (#3154) ice with struct/&<T> prevents these from being structs.
/// The "write permission" token used for RWARC.write_downgrade().
enum RWWriteMode<T: const send> =
enum RWWriteMode<T: Const Send> =
(&mut T, sync::RWlockWriteMode, PoisonOnFail);
/// The "read permission" token used for RWARC.write_downgrade().
enum RWReadMode<T:const send> = (&T, sync::RWlockReadMode);
enum RWReadMode<T:Const Send> = (&T, sync::RWlockReadMode);
impl<T: const send> &RWWriteMode<T> {
impl<T: Const Send> &RWWriteMode<T> {
/// Access the pre-downgrade RWARC in write mode.
fn write<U>(blk: fn(x: &mut T) -> U) -> U {
match *self {
@ -427,7 +427,7 @@ impl<T: const send> &RWWriteMode<T> {
}
}
impl<T: const send> &RWReadMode<T> {
impl<T: Const Send> &RWReadMode<T> {
/// Access the post-downgrade rwlock in read mode.
fn read<U>(blk: fn(x: &T) -> U) -> U {
match *self {

View File

@ -107,7 +107,7 @@ unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@())
*
* Fails if `ofs` is greater or equal to the length of the vector
*/
fn get<T: copy>(t: CVec<T>, ofs: uint) -> T {
fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T {
assert ofs < len(t);
return unsafe { *ptr::mut_offset((*t).base, ofs) };
}
@ -117,7 +117,7 @@ fn get<T: copy>(t: CVec<T>, ofs: uint) -> T {
*
* Fails if `ofs` is greater or equal to the length of the vector
*/
fn set<T: copy>(t: CVec<T>, ofs: uint, v: T) {
fn set<T: Copy>(t: CVec<T>, ofs: uint, v: T) {
assert ofs < len(t);
unsafe { *ptr::mut_offset((*t).base, ofs) = v };
}

View File

@ -13,7 +13,7 @@ use pipes::{Channel, Recv, Chan, Port, Selectable};
export DuplexStream;
/// An extension of `pipes::stream` that allows both sending and receiving.
struct DuplexStream<T: send, U: send> : Channel<T>, Recv<U>, Selectable {
struct DuplexStream<T: Send, U: Send> : Channel<T>, Recv<U>, Selectable {
priv chan: Chan<T>,
priv port: Port <U>,
@ -43,7 +43,7 @@ struct DuplexStream<T: send, U: send> : Channel<T>, Recv<U>, Selectable {
}
/// Creates a bidirectional stream.
fn DuplexStream<T: send, U: send>()
fn DuplexStream<T: Send, U: Send>()
-> (DuplexStream<T, U>, DuplexStream<U, T>)
{
let (c2, p1) = pipes::stream();

View File

@ -16,7 +16,7 @@ trait Deque<T> {
// FIXME (#2343) eventually, a proper datatype plus an exported impl would
// be preferrable.
fn create<T: copy>() -> Deque<T> {
fn create<T: Copy>() -> Deque<T> {
type Cell<T> = Option<T>;
let initial_capacity: uint = 32u; // 2^5
@ -24,7 +24,7 @@ fn create<T: copy>() -> Deque<T> {
* Grow is only called on full elts, so nelts is also len(elts), unlike
* elsewhere.
*/
fn grow<T: copy>(nelts: uint, lo: uint, -elts: ~[mut Cell<T>]) ->
fn grow<T: Copy>(nelts: uint, lo: uint, -elts: ~[mut Cell<T>]) ->
~[mut Cell<T>] {
assert (nelts == vec::len(elts));
let mut rv = ~[mut];
@ -40,7 +40,7 @@ fn create<T: copy>() -> Deque<T> {
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 }
}
@ -49,7 +49,7 @@ fn create<T: copy>() -> Deque<T> {
mut hi: uint,
elts: DVec<Cell<T>>};
impl <T: copy> Repr<T>: Deque<T> {
impl <T: Copy> Repr<T>: Deque<T> {
fn size() -> uint { return self.nelts; }
fn add_front(t: T) {
let oldlo: uint = self.lo;
@ -193,7 +193,7 @@ mod tests {
type EqFn<T> = fn@(T, T) -> bool;
fn test_parameterized<T: copy owned>(
fn test_parameterized<T: Copy Owned>(
e: EqFn<T>, a: T, b: T, c: T, d: T) {
let deq: deque::Deque<T> = deque::create::<T>();

View File

@ -33,7 +33,7 @@ enum TreeNode<K, V> {
fn init<K, V>() -> Treemap<K, V> { @Empty }
/// Insert a value into the map
fn insert<K: copy Eq Ord, V: copy>(m: Treemap<K, V>, +k: K, +v: V)
fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K, +v: V)
-> Treemap<K, V> {
@match m {
@Empty => Node(@k, @v, @Empty, @Empty),
@ -48,7 +48,7 @@ fn insert<K: copy Eq Ord, V: copy>(m: Treemap<K, V>, +k: K, +v: V)
}
/// Find a value based on the key
fn find<K: Eq Ord, V: copy>(m: Treemap<K, V>, +k: K) -> Option<V> {
fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, +k: K) -> Option<V> {
match *m {
Empty => None,
Node(@kk, @v, left, right) => {
@ -60,7 +60,7 @@ fn find<K: Eq Ord, V: copy>(m: Treemap<K, V>, +k: K) -> Option<V> {
}
/// Visit all pairs in the map in order.
fn traverse<K, V: copy>(m: Treemap<K, V>, f: fn(K, V)) {
fn traverse<K, V: Copy>(m: Treemap<K, V>, f: fn(K, V)) {
match *m {
Empty => (),
/*

View File

@ -720,7 +720,7 @@ impl <A: ToJson> ~[A]: ToJson {
fn to_json() -> Json { List(@self.map(|elt| elt.to_json())) }
}
impl <A: ToJson copy> hashmap<~str, A>: ToJson {
impl <A: ToJson Copy> hashmap<~str, A>: ToJson {
fn to_json() -> Json {
let d = map::str_hash();
for self.each() |key, value| {

View File

@ -13,7 +13,7 @@ enum List<T> {
}
/// Cregate a list from a vector
fn from_vec<T: copy>(v: &[T]) -> @List<T> {
fn from_vec<T: Copy>(v: &[T]) -> @List<T> {
vec::foldr(v, @Nil::<T>, |h, t| @Cons(h, t))
}
@ -30,7 +30,7 @@ fn from_vec<T: copy>(v: &[T]) -> @List<T> {
* * z - The initial value
* * f - The function to apply
*/
fn foldl<T: copy, U>(+z: T, ls: @List<U>, f: fn((&T), (&U)) -> T) -> T {
fn foldl<T: Copy, U>(+z: T, ls: @List<U>, f: fn((&T), (&U)) -> T) -> T {
let mut accum: T = z;
do iter(ls) |elt| { accum = f(&accum, &elt);}
accum
@ -43,7 +43,7 @@ fn foldl<T: copy, U>(+z: T, ls: @List<U>, f: fn((&T), (&U)) -> T) -> T {
* When function `f` returns true then an option containing the element
* is returned. If `f` matches no elements then none is returned.
*/
fn find<T: copy>(ls: @List<T>, f: fn((&T)) -> bool) -> Option<T> {
fn find<T: Copy>(ls: @List<T>, f: fn((&T)) -> bool) -> Option<T> {
let mut ls = ls;
loop {
ls = match *ls {
@ -57,7 +57,7 @@ fn find<T: copy>(ls: @List<T>, f: fn((&T)) -> bool) -> Option<T> {
}
/// Returns true if a list contains an element with the given value
fn has<T: copy Eq>(ls: @List<T>, +elt: T) -> bool {
fn has<T: Copy Eq>(ls: @List<T>, +elt: T) -> bool {
for each(ls) |e| {
if e == elt { return true; }
}
@ -65,7 +65,7 @@ fn has<T: copy Eq>(ls: @List<T>, +elt: T) -> bool {
}
/// Returns true if the list is empty
pure fn is_empty<T: copy>(ls: @List<T>) -> bool {
pure fn is_empty<T: Copy>(ls: @List<T>) -> bool {
match *ls {
Nil => true,
_ => false
@ -73,7 +73,7 @@ pure fn is_empty<T: copy>(ls: @List<T>) -> bool {
}
/// Returns true if the list is not empty
pure fn is_not_empty<T: copy>(ls: @List<T>) -> bool {
pure fn is_not_empty<T: Copy>(ls: @List<T>) -> bool {
return !is_empty(ls);
}
@ -85,7 +85,7 @@ fn len<T>(ls: @List<T>) -> uint {
}
/// Returns all but the first element of a list
pure fn tail<T: copy>(ls: @List<T>) -> @List<T> {
pure fn tail<T: Copy>(ls: @List<T>) -> @List<T> {
match *ls {
Cons(_, tl) => return tl,
Nil => fail ~"list empty"
@ -93,7 +93,7 @@ pure fn tail<T: copy>(ls: @List<T>) -> @List<T> {
}
/// Returns the first element of a list
pure fn head<T: copy>(ls: @List<T>) -> T {
pure fn head<T: Copy>(ls: @List<T>) -> T {
match *ls {
Cons(hd, _) => hd,
// makes me sad
@ -102,7 +102,7 @@ pure fn head<T: copy>(ls: @List<T>) -> T {
}
/// Appends one list to another
pure fn append<T: copy>(l: @List<T>, m: @List<T>) -> @List<T> {
pure fn append<T: Copy>(l: @List<T>, m: @List<T>) -> @List<T> {
match *l {
Nil => return m,
Cons(x, xs) => {
@ -115,7 +115,7 @@ pure fn append<T: copy>(l: @List<T>, m: @List<T>) -> @List<T> {
/*
/// Push one element into the front of a list, returning a new list
/// THIS VERSION DOESN'T ACTUALLY WORK
pure fn push<T: copy>(ll: &mut @list<T>, +vv: T) {
pure fn push<T: Copy>(ll: &mut @list<T>, +vv: T) {
ll = &mut @cons(vv, *ll)
}
*/

View File

@ -24,7 +24,7 @@ type set<K:Eq IterBytes Hash> = hashmap<K, ()>;
type hashmap<K:Eq IterBytes Hash, V> = chained::t<K, V>;
trait map<K:Eq IterBytes Hash copy, V: copy> {
trait map<K:Eq IterBytes Hash Copy, V: Copy> {
/// Return the number of elements in the map
pure fn size() -> uint;
@ -123,7 +123,7 @@ mod chained {
found_after(@entry<K,V>, @entry<K,V>)
}
priv impl<K:Eq IterBytes Hash, V: copy> t<K, V> {
priv impl<K:Eq IterBytes Hash, V: Copy> t<K, V> {
pure fn search_rem(k: &K, h: uint, idx: uint,
e_root: @entry<K,V>) -> search_result<K,V> {
let mut e0 = e_root;
@ -207,7 +207,7 @@ mod chained {
}
}
impl<K:Eq IterBytes Hash copy, V: copy> t<K, V>: map<K, V> {
impl<K:Eq IterBytes Hash Copy, V: Copy> t<K, V>: map<K, V> {
pure fn size() -> uint { self.count }
fn contains_key(+k: K) -> bool {
@ -330,7 +330,7 @@ mod chained {
}
}
impl<K:Eq IterBytes Hash copy ToStr, V: ToStr copy> t<K, V>: ToStr {
impl<K:Eq IterBytes Hash Copy ToStr, V: ToStr Copy> t<K, V>: ToStr {
fn to_writer(wr: io::Writer) {
if self.count == 0u {
wr.write_str(~"{}");
@ -356,7 +356,7 @@ mod chained {
}
}
impl<K:Eq IterBytes Hash copy, V: copy> t<K, V>: ops::Index<K, V> {
impl<K:Eq IterBytes Hash Copy, V: Copy> t<K, V>: ops::Index<K, V> {
pure fn index(&&k: K) -> V {
unchecked {
self.get(k)
@ -368,7 +368,7 @@ mod chained {
vec::to_mut(vec::from_elem(nchains, None))
}
fn mk<K:Eq IterBytes Hash, V: copy>() -> t<K,V> {
fn mk<K:Eq IterBytes Hash, V: Copy>() -> t<K,V> {
let slf: t<K, V> = @hashmap_ {count: 0u,
chains: chains(initial_capacity)};
slf
@ -380,48 +380,48 @@ Function: hashmap
Construct a hashmap.
*/
fn hashmap<K:Eq IterBytes Hash const, V: copy>()
fn hashmap<K:Eq IterBytes Hash Const, V: Copy>()
-> hashmap<K, V> {
chained::mk()
}
/// Construct a hashmap for string-slice keys
fn str_slice_hash<V: copy>() -> hashmap<&str, V> {
fn str_slice_hash<V: Copy>() -> hashmap<&str, V> {
return hashmap();
}
/// Construct a hashmap for string keys
fn str_hash<V: copy>() -> hashmap<~str, V> {
fn str_hash<V: Copy>() -> hashmap<~str, V> {
return hashmap();
}
/// Construct a hashmap for boxed string keys
fn box_str_hash<V: copy>() -> hashmap<@~str, V> {
fn box_str_hash<V: Copy>() -> hashmap<@~str, V> {
hashmap()
}
/// Construct a hashmap for byte string keys
fn bytes_hash<V: copy>() -> hashmap<~[u8], V> {
fn bytes_hash<V: Copy>() -> hashmap<~[u8], V> {
return hashmap();
}
/// Construct a hashmap for int keys
fn int_hash<V: copy>() -> hashmap<int, V> {
fn int_hash<V: Copy>() -> hashmap<int, V> {
return hashmap();
}
/// Construct a hashmap for uint keys
fn uint_hash<V: copy>() -> hashmap<uint, V> {
fn uint_hash<V: Copy>() -> hashmap<uint, V> {
return hashmap();
}
/// Convenience function for adding keys to a hashmap with nil type keys
fn set_add<K:Eq IterBytes Hash const copy>(set: set<K>, +key: K) -> bool {
fn set_add<K:Eq IterBytes Hash Const Copy>(set: set<K>, +key: K) -> bool {
set.insert(key, ())
}
/// Convert a set into a vector.
fn vec_from_set<T:Eq IterBytes Hash copy>(s: set<T>) -> ~[T] {
fn vec_from_set<T:Eq IterBytes Hash Copy>(s: set<T>) -> ~[T] {
let mut v = ~[];
vec::reserve(v, s.size());
do s.each_key() |k| {
@ -432,7 +432,7 @@ fn vec_from_set<T:Eq IterBytes Hash copy>(s: set<T>) -> ~[T] {
}
/// Construct a hashmap from a vector
fn hash_from_vec<K: Eq IterBytes Hash const copy, V: copy>(
fn hash_from_vec<K: Eq IterBytes Hash Const Copy, V: Copy>(
items: &[(K, V)]) -> hashmap<K, V> {
let map = hashmap();
do vec::iter(items) |item| {
@ -443,27 +443,27 @@ fn hash_from_vec<K: Eq IterBytes Hash const copy, V: copy>(
}
/// Construct a hashmap from a vector with string keys
fn hash_from_strs<V: copy>(items: &[(~str, V)]) -> hashmap<~str, V> {
fn hash_from_strs<V: Copy>(items: &[(~str, V)]) -> hashmap<~str, V> {
hash_from_vec(items)
}
/// Construct a hashmap from a vector with byte keys
fn hash_from_bytes<V: copy>(items: &[(~[u8], V)]) -> hashmap<~[u8], V> {
fn hash_from_bytes<V: Copy>(items: &[(~[u8], V)]) -> hashmap<~[u8], V> {
hash_from_vec(items)
}
/// Construct a hashmap from a vector with int keys
fn hash_from_ints<V: copy>(items: &[(int, V)]) -> hashmap<int, V> {
fn hash_from_ints<V: Copy>(items: &[(int, V)]) -> hashmap<int, V> {
hash_from_vec(items)
}
/// Construct a hashmap from a vector with uint keys
fn hash_from_uints<V: copy>(items: &[(uint, V)]) -> hashmap<uint, V> {
fn hash_from_uints<V: Copy>(items: &[(uint, V)]) -> hashmap<uint, V> {
hash_from_vec(items)
}
// XXX Transitional
impl<K: Eq IterBytes Hash copy, V: copy> Managed<LinearMap<K, V>>:
impl<K: Eq IterBytes Hash Copy, V: Copy> Managed<LinearMap<K, V>>:
map<K, V> {
pure fn size() -> uint {
unchecked {

View File

@ -18,7 +18,7 @@ const min_granularity : uint = 1024u;
* This is used to build most of the other parallel vector functions,
* like map or alli.
*/
fn map_slices<A: copy send, B: copy send>(
fn map_slices<A: Copy Send, B: Copy Send>(
xs: &[A],
f: fn() -> fn~(uint, v: &[A]) -> B)
-> ~[B] {
@ -73,7 +73,7 @@ fn map_slices<A: copy send, B: copy send>(
}
/// A parallel version of map.
fn map<A: copy send, B: copy send>(xs: ~[A], f: fn~(A) -> B) -> ~[B] {
fn map<A: Copy Send, B: Copy Send>(xs: ~[A], f: fn~(A) -> B) -> ~[B] {
vec::concat(map_slices(xs, || {
fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
vec::map(slice, |x| f(x))
@ -82,7 +82,7 @@ fn map<A: copy send, B: copy send>(xs: ~[A], f: fn~(A) -> B) -> ~[B] {
}
/// A parallel version of mapi.
fn mapi<A: copy send, B: copy send>(xs: ~[A],
fn mapi<A: Copy Send, B: Copy Send>(xs: ~[A],
f: fn~(uint, A) -> B) -> ~[B] {
let slices = map_slices(xs, || {
fn~(base: uint, slice : &[A], copy f) -> ~[B] {
@ -103,7 +103,7 @@ fn mapi<A: copy send, B: copy send>(xs: ~[A],
* In this case, f is a function that creates functions to run over the
* inner elements. This is to skirt the need for copy constructors.
*/
fn mapi_factory<A: copy send, B: copy send>(
fn mapi_factory<A: Copy Send, B: Copy Send>(
xs: &[A], f: fn() -> fn~(uint, A) -> B) -> ~[B] {
let slices = map_slices(xs, || {
let f = f();
@ -120,7 +120,7 @@ fn mapi_factory<A: copy send, B: copy send>(
}
/// Returns true if the function holds for all elements in the vector.
fn alli<A: copy send>(xs: ~[A], f: fn~(uint, A) -> bool) -> bool {
fn alli<A: Copy Send>(xs: ~[A], f: fn~(uint, A) -> bool) -> bool {
do vec::all(map_slices(xs, || {
fn~(base: uint, slice : &[A], copy f) -> bool {
vec::alli(slice, |i, x| {
@ -131,7 +131,7 @@ fn alli<A: copy send>(xs: ~[A], f: fn~(uint, A) -> bool) -> bool {
}
/// Returns true if the function holds for any elements in the vector.
fn any<A: copy send>(xs: ~[A], f: fn~(A) -> bool) -> bool {
fn any<A: Copy Send>(xs: ~[A], f: fn~(A) -> bool) -> bool {
do vec::any(map_slices(xs, || {
fn~(_base : uint, slice: &[A], copy f) -> bool {
vec::any(slice, |x| f(x))

View File

@ -93,7 +93,7 @@ fn emit_from_vec<S: serializer, T>(s: S, v: ~[T], f: fn(T)) {
}
}
fn read_to_vec<D: deserializer, T: copy>(d: D, f: fn() -> T) -> ~[T] {
fn read_to_vec<D: deserializer, T: Copy>(d: D, f: fn() -> T) -> ~[T] {
do d.read_vec |len| {
do vec::from_fn(len) |i| {
d.read_vec_elt(i, || f())
@ -112,11 +112,11 @@ impl<S: serializer> S: serializer_helpers {
}
trait deserializer_helpers {
fn read_to_vec<T: copy>(f: fn() -> T) -> ~[T];
fn read_to_vec<T: Copy>(f: fn() -> T) -> ~[T];
}
impl<D: deserializer> D: deserializer_helpers {
fn read_to_vec<T: copy>(f: fn() -> T) -> ~[T] {
fn read_to_vec<T: Copy>(f: fn() -> T) -> ~[T] {
read_to_vec(self, f)
}
}
@ -256,7 +256,7 @@ fn serialize_Option<S: serializer,T>(s: S, v: Option<T>, st: fn(T)) {
}
}
fn deserialize_Option<D: deserializer,T: copy>(d: D, st: fn() -> T)
fn deserialize_Option<D: deserializer,T: Copy>(d: D, st: fn() -> T)
-> Option<T> {
do d.read_enum(~"option") {
do d.read_enum_variant |i| {

View File

@ -12,14 +12,14 @@ use map::map;
// FIXME (#2347): Should not be @; there's a bug somewhere in rustc that
// 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>)
}
/// Create a smallintmap
fn mk<T: copy>() -> SmallIntMap<T> {
fn mk<T: Copy>() -> SmallIntMap<T> {
let v = DVec();
return SmallIntMap_(@{v: v});
}
@ -29,7 +29,7 @@ fn mk<T: copy>() -> SmallIntMap<T> {
* the specified key then the original value is replaced.
*/
#[inline(always)]
fn insert<T: copy>(self: SmallIntMap<T>, key: uint, +val: T) {
fn insert<T: Copy>(self: SmallIntMap<T>, key: uint, +val: T) {
//io::println(fmt!("%?", key));
self.v.grow_set_elt(key, None, Some(val));
}
@ -38,7 +38,7 @@ fn insert<T: copy>(self: SmallIntMap<T>, key: uint, +val: T) {
* Get the value for the specified key. If the key does not exist
* in the map then returns none
*/
pure fn find<T: copy>(self: SmallIntMap<T>, key: uint) -> Option<T> {
pure fn find<T: Copy>(self: SmallIntMap<T>, key: uint) -> Option<T> {
if key < self.v.len() { return self.v.get_elt(key); }
return None::<T>;
}
@ -50,7 +50,7 @@ pure fn find<T: copy>(self: SmallIntMap<T>, key: uint) -> Option<T> {
*
* If the key does not exist in the map
*/
pure fn get<T: copy>(self: SmallIntMap<T>, key: uint) -> T {
pure fn get<T: Copy>(self: SmallIntMap<T>, key: uint) -> T {
match find(self, key) {
None => {
error!("smallintmap::get(): key not present");
@ -61,12 +61,12 @@ pure fn get<T: copy>(self: SmallIntMap<T>, key: uint) -> T {
}
/// Returns true if the map contains a value for the specified key
fn contains_key<T: copy>(self: SmallIntMap<T>, key: uint) -> bool {
fn contains_key<T: Copy>(self: SmallIntMap<T>, key: uint) -> bool {
return !option::is_none(find(self, key));
}
/// Implements the map::map interface for smallintmap
impl<V: copy> SmallIntMap<V>: map::map<uint, V> {
impl<V: Copy> SmallIntMap<V>: map::map<uint, V> {
pure fn size() -> uint {
let mut sz = 0u;
for self.v.each |item| {
@ -137,7 +137,7 @@ impl<V: copy> SmallIntMap<V>: map::map<uint, V> {
}
}
impl<V: copy> SmallIntMap<V>: ops::Index<uint, V> {
impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> {
pure fn index(&&key: uint) -> V {
unchecked {
get(self, key)
@ -146,6 +146,6 @@ impl<V: copy> SmallIntMap<V>: ops::Index<uint, V> {
}
/// Cast the given smallintmap to a map::map
fn as_map<V: copy>(s: SmallIntMap<V>) -> map::map<uint, V> {
fn as_map<V: Copy>(s: SmallIntMap<V>) -> map::map<uint, V> {
s as map::map::<uint, V>
}

View File

@ -19,12 +19,12 @@ type Le<T> = pure fn(v1: &T, v2: &T) -> bool;
* Has worst case O(n log n) performance, best case O(n), but
* is not space efficient. This is a stable sort.
*/
fn merge_sort<T: copy>(le: Le<T>, v: &[const T]) -> ~[T] {
fn merge_sort<T: Copy>(le: Le<T>, v: &[const T]) -> ~[T] {
type Slice = (uint, uint);
return merge_sort_(le, v, (0u, len(v)));
fn merge_sort_<T: copy>(le: Le<T>, v: &[const T], slice: Slice)
fn merge_sort_<T: Copy>(le: Le<T>, v: &[const T], slice: Slice)
-> ~[T] {
let begin = slice.first();
let end = slice.second();
@ -39,7 +39,7 @@ fn merge_sort<T: copy>(le: Le<T>, v: &[const T]) -> ~[T] {
return merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b));
}
fn merge<T: copy>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
fn merge<T: Copy>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
let mut rs = ~[];
vec::reserve(rs, len(a) + len(b));
let a_len = len(a);
@ -58,7 +58,7 @@ fn merge_sort<T: copy>(le: Le<T>, v: &[const T]) -> ~[T] {
}
}
fn part<T: copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
fn part<T: Copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
right: uint, pivot: uint) -> uint {
let pivot_value = arr[pivot];
arr[pivot] <-> arr[right];
@ -75,7 +75,7 @@ fn part<T: copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
return storage_index;
}
fn qsort<T: copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
fn qsort<T: Copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
right: uint) {
if right > left {
let pivot = (left + right) / 2u;
@ -94,12 +94,12 @@ fn qsort<T: copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
* Has worst case O(n^2) performance, average case O(n log n).
* This is an unstable sort.
*/
fn quick_sort<T: copy>(compare_func: Le<T>, arr: &[mut T]) {
fn quick_sort<T: Copy>(compare_func: Le<T>, arr: &[mut T]) {
if len::<T>(arr) == 0u { return; }
qsort::<T>(compare_func, arr, 0u, len::<T>(arr) - 1u);
}
fn qsort3<T: copy Ord Eq>(arr: &[mut T], left: int, right: int) {
fn qsort3<T: Copy Ord Eq>(arr: &[mut T], left: int, right: int) {
if right <= left { return; }
let v: T = arr[right];
let mut i: int = left - 1;
@ -156,7 +156,7 @@ fn qsort3<T: copy Ord Eq>(arr: &[mut T], left: int, right: int) {
*
* This is an unstable sort.
*/
fn quick_sort3<T: copy Ord Eq>(arr: &[mut T]) {
fn quick_sort3<T: Copy Ord Eq>(arr: &[mut T]) {
if arr.len() <= 1 { return; }
qsort3(arr, 0, (arr.len() - 1) as int);
}
@ -165,7 +165,7 @@ trait Sort {
fn qsort(self);
}
impl<T: copy Ord Eq> &[mut T] : Sort {
impl<T: Copy Ord Eq> &[mut T] : Sort {
fn qsort(self) { quick_sort3(self); }
}

View File

@ -70,10 +70,10 @@ struct SemInner<Q> {
blocked: Q
}
#[doc(hidden)]
enum Sem<Q: send> = Exclusive<SemInner<Q>>;
enum Sem<Q: Send> = Exclusive<SemInner<Q>>;
#[doc(hidden)]
fn new_sem<Q: send>(count: int, +q: Q) -> Sem<Q> {
fn new_sem<Q: Send>(count: int, +q: Q) -> Sem<Q> {
Sem(exclusive(SemInner {
mut count: count, waiters: new_waitqueue(), blocked: q }))
}
@ -88,7 +88,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint)
}
#[doc(hidden)]
impl<Q: send> &Sem<Q> {
impl<Q: Send> &Sem<Q> {
fn acquire() {
let mut waiter_nobe = None;
unsafe {

View File

@ -26,7 +26,7 @@ export delayed_send, sleep, recv_timeout;
* * ch - a channel of type T to send a `val` on
* * val - a value of type T to send over the provided `ch`
*/
fn delayed_send<T: copy send>(iotask: IoTask,
fn delayed_send<T: Copy Send>(iotask: IoTask,
msecs: uint, ch: comm::Chan<T>, +val: T) {
unsafe {
let timer_done_po = core::comm::Port::<()>();
@ -102,7 +102,7 @@ fn sleep(iotask: IoTask, msecs: uint) {
* on the provided port in the allotted timeout period, then the result will
* be a `some(T)`. If not, then `none` will be returned.
*/
fn recv_timeout<T: copy send>(iotask: IoTask,
fn recv_timeout<T: Copy Send>(iotask: IoTask,
msecs: uint,
wait_po: comm::Port<T>) -> Option<T> {
let timeout_po = comm::Port::<()>();

View File

@ -32,7 +32,7 @@ enum TreeNode<K, V> = {
fn TreeMap<K, V>() -> TreeMap<K, V> { @mut None }
/// Insert a value into the map
fn insert<K: copy Eq Ord, V: copy>(m: &mut TreeEdge<K, V>, +k: K, +v: V) {
fn insert<K: Copy Eq Ord, V: Copy>(m: &mut TreeEdge<K, V>, +k: K, +v: V) {
match copy *m {
None => {
*m = Some(@TreeNode({key: k,
@ -54,7 +54,7 @@ fn insert<K: copy Eq Ord, V: copy>(m: &mut TreeEdge<K, V>, +k: K, +v: V) {
}
/// Find a value based on the key
fn find<K: copy Eq Ord, V: copy>(m: &const TreeEdge<K, V>, +k: K)
fn find<K: Copy Eq Ord, V: Copy>(m: &const TreeEdge<K, V>, +k: K)
-> Option<V> {
match copy *m {
None => None,
@ -73,7 +73,7 @@ fn find<K: copy Eq Ord, V: copy>(m: &const TreeEdge<K, V>, +k: K)
}
/// Visit all pairs in the map in order.
fn traverse<K, V: copy>(m: &const TreeEdge<K, V>, f: fn(K, V)) {
fn traverse<K, V: Copy>(m: &const TreeEdge<K, V>, f: fn(K, V)) {
match copy *m {
None => (),
Some(node) => {

View File

@ -259,7 +259,7 @@ impl def_id : core::to_bytes::IterBytes {
}
}
fn new_def_hash<V: copy>() -> std::map::hashmap<ast::def_id, V> {
fn new_def_hash<V: Copy>() -> std::map::hashmap<ast::def_id, V> {
return std::map::hashmap::<ast::def_id, V>();
}

View File

@ -271,7 +271,7 @@ fn print_macro_backtrace(cm: codemap::codemap, sp: span) {
}
}
fn expect<T: copy>(diag: span_handler,
fn expect<T: Copy>(diag: span_handler,
opt: Option<T>, msg: fn() -> ~str) -> T {
match opt {
Some(t) => t,

View File

@ -88,7 +88,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) ->
}
}
fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> Option<U>, v: ~[T]) ->
fn option_flatten_map<T: Copy, U: Copy>(f: fn@(T) -> Option<U>, v: ~[T]) ->
Option<~[U]> {
let mut res = ~[];
for v.each |elem| {

View File

@ -41,21 +41,21 @@ trait parser_common {
fn check_restricted_keywords();
fn check_restricted_keywords_(w: ~str);
fn expect_gt();
fn parse_seq_to_before_gt<T: copy>(sep: Option<token::token>,
fn parse_seq_to_before_gt<T: Copy>(sep: Option<token::token>,
f: fn(parser) -> T) -> ~[T];
fn parse_seq_to_gt<T: copy>(sep: Option<token::token>,
fn parse_seq_to_gt<T: Copy>(sep: Option<token::token>,
f: fn(parser) -> T) -> ~[T];
fn parse_seq_lt_gt<T: copy>(sep: Option<token::token>,
fn parse_seq_lt_gt<T: Copy>(sep: Option<token::token>,
f: fn(parser) -> T) -> spanned<~[T]>;
fn parse_seq_to_end<T: copy>(ket: token::token, sep: seq_sep,
fn parse_seq_to_end<T: Copy>(ket: token::token, sep: seq_sep,
f: fn(parser) -> T) -> ~[T];
fn parse_seq_to_before_end<T: copy>(ket: token::token, sep: seq_sep,
fn parse_seq_to_before_end<T: Copy>(ket: token::token, sep: seq_sep,
f: fn(parser) -> T) -> ~[T];
fn parse_unspanned_seq<T: copy>(bra: token::token,
fn parse_unspanned_seq<T: Copy>(bra: token::token,
ket: token::token,
sep: seq_sep,
f: fn(parser) -> T) -> ~[T];
fn parse_seq<T: copy>(bra: token::token, ket: token::token, sep: seq_sep,
fn parse_seq<T: Copy>(bra: token::token, ket: token::token, sep: seq_sep,
f: fn(parser) -> T) -> spanned<~[T]>;
}
@ -198,7 +198,7 @@ impl parser: parser_common {
}
}
fn parse_seq_to_before_gt<T: copy>(sep: Option<token::token>,
fn parse_seq_to_before_gt<T: Copy>(sep: Option<token::token>,
f: fn(parser) -> T) -> ~[T] {
let mut first = true;
let mut v = ~[];
@ -217,7 +217,7 @@ impl parser: parser_common {
return v;
}
fn parse_seq_to_gt<T: copy>(sep: Option<token::token>,
fn parse_seq_to_gt<T: Copy>(sep: Option<token::token>,
f: fn(parser) -> T) -> ~[T] {
let v = self.parse_seq_to_before_gt(sep, f);
self.expect_gt();
@ -225,7 +225,7 @@ impl parser: parser_common {
return v;
}
fn parse_seq_lt_gt<T: copy>(sep: Option<token::token>,
fn parse_seq_lt_gt<T: Copy>(sep: Option<token::token>,
f: fn(parser) -> T) -> spanned<~[T]> {
let lo = self.span.lo;
self.expect(token::LT);
@ -235,7 +235,7 @@ impl parser: parser_common {
return spanned(lo, hi, result);
}
fn parse_seq_to_end<T: copy>(ket: token::token, sep: seq_sep,
fn parse_seq_to_end<T: Copy>(ket: token::token, sep: seq_sep,
f: fn(parser) -> T) -> ~[T] {
let val = self.parse_seq_to_before_end(ket, sep, f);
self.bump();
@ -243,7 +243,7 @@ impl parser: parser_common {
}
fn parse_seq_to_before_end<T: copy>(ket: token::token, sep: seq_sep,
fn parse_seq_to_before_end<T: Copy>(ket: token::token, sep: seq_sep,
f: fn(parser) -> T) -> ~[T] {
let mut first: bool = true;
let mut v: ~[T] = ~[];
@ -261,7 +261,7 @@ impl parser: parser_common {
return v;
}
fn parse_unspanned_seq<T: copy>(bra: token::token,
fn parse_unspanned_seq<T: Copy>(bra: token::token,
ket: token::token,
sep: seq_sep,
f: fn(parser) -> T) -> ~[T] {
@ -273,7 +273,7 @@ impl parser: parser_common {
// NB: Do not use this function unless you actually plan to place the
// spanned list in the AST.
fn parse_seq<T: copy>(bra: token::token, ket: token::token, sep: seq_sep,
fn parse_seq<T: Copy>(bra: token::token, ket: token::token, sep: seq_sep,
f: fn(parser) -> T) -> spanned<~[T]> {
let lo = self.span.lo;
self.expect(bra);

View File

@ -2278,15 +2278,7 @@ struct parser {
let mut bounds = ~[];
if self.eat(token::COLON) {
while is_ident(self.token) {
if self.eat_keyword(~"send") {
push(bounds, bound_send); }
else if self.eat_keyword(~"copy") {
push(bounds, bound_copy) }
else if self.eat_keyword(~"const") {
push(bounds, bound_const);
} else if self.eat_keyword(~"owned") {
push(bounds, bound_owned);
} else if is_ident(self.token) {
if is_ident(self.token) {
// XXX: temporary until kinds become traits
let maybe_bound = match self.token {
token::IDENT(sid, _) => {

View File

@ -386,7 +386,7 @@ fn contextual_keyword_table() -> hashmap<~str, ()> {
~"else",
~"move",
~"priv", ~"pub",
~"self", ~"send", ~"static",
~"self", ~"static",
~"use"
];
for keys.each |word| {
@ -421,7 +421,6 @@ fn restricted_keyword_table() -> hashmap<~str, ()> {
~"if", ~"impl", ~"import",
~"let", ~"log", ~"loop",
~"match", ~"mod", ~"move", ~"mut",
~"owned",
~"pure",
~"ref", ~"return",
~"struct",

View File

@ -1658,10 +1658,10 @@ fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) {
for vec::each(*bounds) |bound| {
nbsp(s);
match bound {
ast::bound_copy => word(s.s, ~"copy"),
ast::bound_send => word(s.s, ~"send"),
ast::bound_const => word(s.s, ~"const"),
ast::bound_owned => word(s.s, ~"owned"),
ast::bound_copy => word(s.s, ~"Copy"),
ast::bound_send => word(s.s, ~"Send"),
ast::bound_const => word(s.s, ~"Const"),
ast::bound_owned => word(s.s, ~"Owned"),
ast::bound_trait(t) => print_type(s, t)
}
}

View File

@ -8,18 +8,18 @@ use cmp::Eq;
use hash::Hash;
use to_bytes::IterBytes;
type hash_interner<T: const> =
type hash_interner<T: Const> =
{map: hashmap<T, uint>,
vect: DVec<T>};
fn mk<T:Eq IterBytes Hash const copy>() -> interner<T> {
fn mk<T:Eq IterBytes Hash Const Copy>() -> interner<T> {
let m = map::hashmap::<T, uint>();
let hi: hash_interner<T> =
{map: m, vect: DVec()};
return hi as interner::<T>;
}
fn mk_prefill<T:Eq IterBytes Hash const copy>(init: ~[T]) -> interner<T> {
fn mk_prefill<T:Eq IterBytes Hash Const Copy>(init: ~[T]) -> interner<T> {
let rv = mk();
for init.each() |v| { rv.intern(v); }
return rv;
@ -27,14 +27,14 @@ fn mk_prefill<T:Eq IterBytes Hash const copy>(init: ~[T]) -> interner<T> {
/* when traits can extend traits, we should extend index<uint,T> to get [] */
trait interner<T:Eq IterBytes Hash const copy> {
trait interner<T:Eq IterBytes Hash Const Copy> {
fn intern(T) -> uint;
fn gensym(T) -> uint;
pure fn get(uint) -> T;
fn len() -> uint;
}
impl <T:Eq IterBytes Hash const copy> hash_interner<T>: interner<T> {
impl <T:Eq IterBytes Hash Const Copy> hash_interner<T>: interner<T> {
fn intern(val: T) -> uint {
match self.map.find(val) {
Some(idx) => return idx,

View File

@ -271,7 +271,7 @@ fn basic_options() -> @options {
}
// Seems out of place, but it uses session, so I'm putting it here
fn expect<T: copy>(sess: session, opt: Option<T>, msg: fn() -> ~str) -> T {
fn expect<T: Copy>(sess: session, opt: Option<T>, msg: fn() -> ~str) -> T {
diagnostic::expect(sess.diagnostic(), opt, msg)
}

View File

@ -22,7 +22,7 @@ fn use_core(crate: @ast::crate) -> bool {
fn inject_libcore_ref(sess: session,
crate: @ast::crate) -> @ast::crate {
fn spanned<T: copy>(x: T) -> @ast::spanned<T> {
fn spanned<T: Copy>(x: T) -> @ast::spanned<T> {
return @{node: x,
span: dummy_sp()};
}

View File

@ -212,7 +212,7 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
return @item;
}
fn nospan<T: copy>(t: T) -> ast::spanned<T> {
fn nospan<T: Copy>(t: T) -> ast::spanned<T> {
return {node: t, span: dummy_sp()};
}

View File

@ -866,7 +866,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::Writer,
// Path and definition ID indexing
fn create_index<T: copy>(index: ~[entry<T>], hash_fn: fn@(T) -> uint) ->
fn create_index<T: Copy>(index: ~[entry<T>], hash_fn: fn@(T) -> uint) ->
~[@~[entry<T>]] {
let mut buckets: ~[@mut ~[entry<T>]] = ~[];
for uint::range(0u, 256u) |_i| { vec::push(buckets, @mut ~[]); };

View File

@ -67,7 +67,7 @@ fn mk_filesearch(maybe_sysroot: Option<Path>,
target_triple: str::from_slice(target_triple)} as filesearch
}
fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> Option<T> {
fn search<T: Copy>(filesearch: filesearch, pick: pick<T>) -> Option<T> {
let mut rslt = None;
for filesearch.lib_search_paths().each |lib_search_path| {
debug!("searching %s", lib_search_path.to_str());

View File

@ -396,7 +396,7 @@ type req_maps = {
pure_map: hashmap<ast::node_id, bckerr>
};
fn save_and_restore<T:copy,U>(&save_and_restore_t: T, f: fn() -> U) -> U {
fn save_and_restore<T:Copy,U>(&save_and_restore_t: T, f: fn() -> U) -> U {
let old_save_and_restore_t = save_and_restore_t;
let u <- f();
save_and_restore_t = old_save_and_restore_t;

View File

@ -308,7 +308,7 @@ fn Atom(n: uint) -> Atom {
}
/// Creates a hash table of atoms.
fn atom_hashmap<V:copy>() -> hashmap<Atom,V> {
fn atom_hashmap<V:Copy>() -> hashmap<Atom,V> {
hashmap::<Atom,V>()
}

View File

@ -129,7 +129,7 @@ enum debug_metadata {
retval_metadata(@metadata<retval_md>),
}
fn cast_safely<T: copy, U>(val: T) -> U unsafe {
fn cast_safely<T: Copy, U>(val: T) -> U unsafe {
let val2 = val;
return unsafe::transmute(val2);
}
@ -147,7 +147,7 @@ fn md_from_metadata<T>(val: debug_metadata) -> T unsafe {
}
}
fn cached_metadata<T: copy>(cache: metadata_cache, mdtag: int,
fn cached_metadata<T: Copy>(cache: metadata_cache, mdtag: int,
eq: fn(md: T) -> bool) -> Option<T> unsafe {
if cache.contains_key(mdtag) {
let items = cache.get(mdtag);

View File

@ -58,7 +58,7 @@ fn mk_nominal_id(tcx: ty::ctxt, did: ast::def_id,
@{did: did, parent_id: parent_id, tps: tps_norm}
}
fn new_nominal_id_hash<T: copy>() -> hashmap<nominal_id, T> {
fn new_nominal_id_hash<T: Copy>() -> hashmap<nominal_id, T> {
return hashmap();
}

View File

@ -799,7 +799,7 @@ fn mk_rcache() -> creader_cache {
return map::hashmap();
}
fn new_ty_hash<V: copy>() -> map::hashmap<t, V> {
fn new_ty_hash<V: Copy>() -> map::hashmap<t, V> {
map::hashmap()
}
@ -2568,7 +2568,7 @@ pure fn hash_bound_region(br: &bound_region) -> uint {
}
}
fn br_hashmap<V:copy>() -> hashmap<bound_region, V> {
fn br_hashmap<V:Copy>() -> hashmap<bound_region, V> {
map::hashmap()
}
@ -3081,7 +3081,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: TyVid, rt: t) {
// Maintains a little union-set tree for inferred modes. `canon()` returns
// the current head value for `m0`.
fn canon<T:copy>(tbl: hashmap<ast::node_id, ast::inferable<T>>,
fn canon<T:Copy>(tbl: hashmap<ast::node_id, ast::inferable<T>>,
+m0: ast::inferable<T>) -> ast::inferable<T> {
match m0 {
ast::infer(id) => match tbl.find(id) {

View File

@ -69,7 +69,7 @@ fn get_region_reporting_err(tcx: ty::ctxt,
}
}
fn ast_region_to_region<AC: ast_conv, RS: region_scope copy owned>(
fn ast_region_to_region<AC: ast_conv, RS: region_scope Copy Owned>(
self: AC, rscope: RS, span: span, a_r: @ast::region) -> ty::region {
let res = match a_r.node {
@ -80,7 +80,7 @@ fn ast_region_to_region<AC: ast_conv, RS: region_scope copy owned>(
get_region_reporting_err(self.tcx(), span, res)
}
fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope copy owned>(
fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope Copy Owned>(
self: AC, rscope: RS, did: ast::def_id,
path: @ast::path) -> ty_param_substs_and_ty {
@ -129,7 +129,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope copy owned>(
{substs: substs, ty: ty::subst(tcx, &substs, decl_ty)}
}
fn ast_path_to_ty<AC: ast_conv, RS: region_scope copy owned>(
fn ast_path_to_ty<AC: ast_conv, RS: region_scope Copy Owned>(
self: AC,
rscope: RS,
did: ast::def_id,
@ -152,10 +152,10 @@ const NO_TPS: uint = 2u;
// Parses the programmer's textual representation of a type into our
// internal notion of a type. `getter` is a function that returns the type
// corresponding to a definition ID:
fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
fn ast_ty_to_ty<AC: ast_conv, RS: region_scope Copy Owned>(
self: AC, rscope: RS, &&ast_ty: @ast::ty) -> ty::t {
fn ast_mt_to_mt<AC: ast_conv, RS: region_scope copy owned>(
fn ast_mt_to_mt<AC: ast_conv, RS: region_scope Copy Owned>(
self: AC, rscope: RS, mt: ast::mt) -> ty::mt {
return {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl};
@ -164,7 +164,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
// Handle @, ~, and & being able to mean estrs and evecs.
// If a_seq_ty is a str or a vec, make it an estr/evec.
// Also handle function sigils and first-class trait types.
fn mk_maybe_vstore<AC: ast_conv, RS: region_scope copy owned>(
fn mk_maybe_vstore<AC: ast_conv, RS: region_scope Copy Owned>(
self: AC, rscope: RS, a_seq_ty: ast::mt, vst: ty::vstore,
span: span, constr: fn(ty::mt) -> ty::t) -> ty::t {
@ -400,7 +400,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
return typ;
}
fn ty_of_arg<AC: ast_conv, RS: region_scope copy owned>(
fn ty_of_arg<AC: ast_conv, RS: region_scope Copy Owned>(
self: AC, rscope: RS, a: ast::arg,
expected_ty: Option<ty::arg>) -> ty::arg {
@ -445,7 +445,7 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope copy owned>(
{mode: mode, ty: ty}
}
fn ast_proto_to_proto<AC: ast_conv, RS: region_scope copy owned>(
fn ast_proto_to_proto<AC: ast_conv, RS: region_scope Copy Owned>(
self: AC, rscope: RS, span: span, ast_proto: ast::proto) -> ty::fn_proto {
match ast_proto {
ast::proto_bare =>
@ -465,7 +465,7 @@ fn ast_proto_to_proto<AC: ast_conv, RS: region_scope copy owned>(
type expected_tys = Option<{inputs: ~[ty::arg],
output: ty::t}>;
fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy owned>(
fn ty_of_fn_decl<AC: ast_conv, RS: region_scope Copy Owned>(
self: AC, rscope: RS,
ast_proto: ast::proto,
purity: ast::purity,

View File

@ -1203,7 +1203,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
// through the `unpack` function. It there is no expected type or
// resolution is not possible (e.g., no constraints yet present), just
// returns `none`.
fn unpack_expected<O: copy>(fcx: @fn_ctxt, expected: Option<ty::t>,
fn unpack_expected<O: Copy>(fcx: @fn_ctxt, expected: Option<ty::t>,
unpack: fn(ty::sty) -> Option<O>)
-> Option<O> {
match expected {

View File

@ -75,7 +75,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
}
impl @crate_ctxt {
fn to_ty<RS: region_scope copy owned>(
fn to_ty<RS: region_scope Copy Owned>(
rs: RS, ast_ty: @ast::ty) -> ty::t {
ast_ty_to_ty(self, rs, ast_ty)

View File

@ -298,8 +298,8 @@ export assignment;
export root, to_str;
export int_ty_set_all;
type bound<T:copy> = Option<T>;
type bounds<T:copy> = {lb: bound<T>, ub: bound<T>};
type bound<T:Copy> = Option<T>;
type bounds<T:Copy> = {lb: bound<T>, ub: bound<T>};
type cres<T> = Result<T,ty::type_err>; // "combine result"
type ures = cres<()>; // "unify result"
@ -348,7 +348,7 @@ fn fixup_err_to_str(f: fixup_err) -> ~str {
}
}
fn new_vals_and_bindings<V:copy, T:copy>() -> vals_and_bindings<V, T> {
fn new_vals_and_bindings<V:Copy, T:Copy>() -> vals_and_bindings<V, T> {
vals_and_bindings {
vals: smallintmap::mk(),
mut bindings: ~[]
@ -458,12 +458,12 @@ fn resolve_borrowings(cx: infer_ctxt) {
*/
trait then {
fn then<T:copy>(f: fn() -> Result<T,ty::type_err>)
fn then<T:Copy>(f: fn() -> Result<T,ty::type_err>)
-> Result<T,ty::type_err>;
}
impl ures: then {
fn then<T:copy>(f: fn() -> Result<T,ty::type_err>)
fn then<T:Copy>(f: fn() -> Result<T,ty::type_err>)
-> Result<T,ty::type_err> {
self.chain(|_i| f())
}
@ -474,7 +474,7 @@ trait cres_helpers<T> {
fn compare(t: T, f: fn() -> ty::type_err) -> cres<T>;
}
impl<T:copy Eq> cres<T>: cres_helpers<T> {
impl<T:Copy Eq> cres<T>: cres_helpers<T> {
fn to_ures() -> ures {
match self {
Ok(_v) => Ok(()),
@ -497,7 +497,7 @@ fn uok() -> ures {
Ok(())
}
fn rollback_to<V:copy vid, T:copy>(
fn rollback_to<V:Copy vid, T:Copy>(
vb: &vals_and_bindings<V, T>, len: uint) {
while vb.bindings.len() != len {

View File

@ -23,7 +23,7 @@ impl ty::region: to_str {
}
}
impl<V:copy to_str> bound<V>: to_str {
impl<V:Copy to_str> bound<V>: to_str {
fn to_str(cx: infer_ctxt) -> ~str {
match self {
Some(v) => v.to_str(cx),
@ -32,7 +32,7 @@ impl<V:copy to_str> bound<V>: to_str {
}
}
impl<T:copy to_str> bounds<T>: to_str {
impl<T:Copy to_str> bounds<T>: to_str {
fn to_str(cx: infer_ctxt) -> ~str {
fmt!("{%s <: %s}",
self.lb.to_str(cx),
@ -48,7 +48,7 @@ impl int_ty_set: to_str {
}
}
impl<V:copy vid, T:copy to_str> var_value<V, T>: to_str {
impl<V:Copy vid, T:Copy to_str> var_value<V, T>: to_str {
fn to_str(cx: infer_ctxt) -> ~str {
match self {
redirect(vid) => fmt!("redirect(%s)", vid.to_str()),

View File

@ -3,24 +3,24 @@ use integral::*;
use to_str::to_str;
use std::smallintmap::SmallIntMap;
enum var_value<V:copy, T:copy> {
enum var_value<V:Copy, T:Copy> {
redirect(V),
root(T, uint),
}
struct vals_and_bindings<V:copy, T:copy> {
struct vals_and_bindings<V:Copy, T:Copy> {
vals: SmallIntMap<var_value<V, T>>,
mut bindings: ~[(V, var_value<V, T>)],
}
struct node<V:copy, T:copy> {
struct node<V:Copy, T:Copy> {
root: V,
possible_types: T,
rank: uint,
}
impl infer_ctxt {
fn get<V:copy vid, T:copy>(
fn get<V:Copy vid, T:Copy>(
vb: &vals_and_bindings<V, T>, vid: V) -> node<V, T> {
let vid_u = vid.to_uint();
@ -46,7 +46,7 @@ impl infer_ctxt {
}
}
fn set<V:copy vid, T:copy to_str>(
fn set<V:Copy vid, T:Copy to_str>(
vb: &vals_and_bindings<V, T>, vid: V,
+new_v: var_value<V, T>) {

View File

@ -46,7 +46,7 @@ fn bound_self_region(rp: Option<ty::region_variance>) -> Option<ty::region> {
}
enum anon_rscope = {anon: ty::region, base: region_scope};
fn in_anon_rscope<RS: region_scope copy owned>(self: RS, r: ty::region)
fn in_anon_rscope<RS: region_scope Copy Owned>(self: RS, r: ty::region)
-> @anon_rscope {
@anon_rscope({anon: r, base: self as region_scope})
}
@ -63,7 +63,7 @@ struct binding_rscope {
base: region_scope,
mut anon_bindings: uint,
}
fn in_binding_rscope<RS: region_scope copy owned>(self: RS)
fn in_binding_rscope<RS: region_scope Copy Owned>(self: RS)
-> @binding_rscope {
let base = self as region_scope;
@binding_rscope { base: base, anon_bindings: 0 }

View File

@ -88,7 +88,7 @@ fn act(po: comm::Port<msg>, source: ~str, parse: parser) {
}
}
fn exec<T:send>(
fn exec<T:Send>(
srv: srv,
+f: fn~(ctxt: ctxt) -> T
) -> T {

View File

@ -89,7 +89,7 @@ fn fold_item(
}
}
fn parse_item_attrs<T:send>(
fn parse_item_attrs<T:Send>(
srv: astsrv::srv,
id: doc::ast_id,
+parse_attrs: fn~(~[ast::attribute]) -> T) -> T {

View File

@ -50,7 +50,7 @@ type t<T> = {
// This exists because fn types don't infer correctly as record
// initializers, but they do as function arguments
fn mk_fold<T:copy>(
fn mk_fold<T:Copy>(
ctxt: T,
+fold_doc: fold_doc<T>,
+fold_crate: fold_crate<T>,
@ -80,7 +80,7 @@ fn mk_fold<T:copy>(
})
}
fn default_any_fold<T:send copy>(ctxt: T) -> fold<T> {
fn default_any_fold<T:Send Copy>(ctxt: T) -> fold<T> {
mk_fold(
ctxt,
|f, d| default_seq_fold_doc(f, d),
@ -97,7 +97,7 @@ fn default_any_fold<T:send copy>(ctxt: T) -> fold<T> {
)
}
fn default_seq_fold<T:copy>(ctxt: T) -> fold<T> {
fn default_seq_fold<T:Copy>(ctxt: T) -> fold<T> {
mk_fold(
ctxt,
|f, d| default_seq_fold_doc(f, d),
@ -114,7 +114,7 @@ fn default_seq_fold<T:copy>(ctxt: T) -> fold<T> {
)
}
fn default_par_fold<T:send copy>(ctxt: T) -> fold<T> {
fn default_par_fold<T:Send Copy>(ctxt: T) -> fold<T> {
mk_fold(
ctxt,
|f, d| default_seq_fold_doc(f, d),
@ -163,7 +163,7 @@ fn default_seq_fold_item<T>(
doc
}
fn default_any_fold_mod<T:send copy>(
fn default_any_fold_mod<T:Send Copy>(
fold: fold<T>,
doc: doc::moddoc
) -> doc::moddoc {
@ -189,7 +189,7 @@ fn default_seq_fold_mod<T>(
})
}
fn default_par_fold_mod<T:send copy>(
fn default_par_fold_mod<T:Send Copy>(
fold: fold<T>,
doc: doc::moddoc
) -> doc::moddoc {
@ -202,7 +202,7 @@ fn default_par_fold_mod<T:send copy>(
})
}
fn default_any_fold_nmod<T:send copy>(
fn default_any_fold_nmod<T:Send Copy>(
fold: fold<T>,
doc: doc::nmoddoc
) -> doc::nmoddoc {
@ -228,7 +228,7 @@ fn default_seq_fold_nmod<T>(
}
}
fn default_par_fold_nmod<T:send copy>(
fn default_par_fold_nmod<T:Send Copy>(
fold: fold<T>,
doc: doc::nmoddoc
) -> doc::nmoddoc {

View File

@ -2,7 +2,7 @@ export foo;
use comm::*;
fn foo<T: send copy>(x: T) -> Port<T> {
fn foo<T: Send Copy>(x: T) -> Port<T> {
let p = Port();
let c = Chan(p);
do task::spawn() |copy c, copy x| {

View File

@ -3,11 +3,11 @@ use dvec::DVec;
type entry<A,B> = {key: A, value: 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});
}
fn alist_get<A: copy, B: copy>(lst: alist<A,B>, k: A) -> B {
fn alist_get<A: Copy, B: Copy>(lst: alist<A,B>, k: A) -> B {
let eq_fn = lst.eq_fn;
for lst.data.each |entry| {
if eq_fn(entry.key, k) { return entry.value; }
@ -16,13 +16,13 @@ fn alist_get<A: copy, B: copy>(lst: alist<A,B>, k: A) -> B {
}
#[inline]
fn new_int_alist<B: copy>() -> alist<int, B> {
fn new_int_alist<B: Copy>() -> alist<int, B> {
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
return {eq_fn: eq_int, data: DVec()};
}
#[inline]
fn new_int_alist_2<B: copy>() -> alist<int, B> {
fn new_int_alist_2<B: Copy>() -> alist<int, B> {
#[inline]
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
return {eq_fn: eq_int, data: DVec()};

View File

@ -7,18 +7,18 @@ use std;
export context;
struct arc_destruct<T:const> {
struct arc_destruct<T:Const> {
_data: int,
drop {}
}
fn arc_destruct<T: const>(data: int) -> arc_destruct<T> {
fn arc_destruct<T: Const>(data: int) -> arc_destruct<T> {
arc_destruct {
_data: data
}
}
fn arc<T: const>(_data: T) -> arc_destruct<T> {
fn arc<T: Const>(_data: T) -> arc_destruct<T> {
arc_destruct(0)
}

View File

@ -10,6 +10,6 @@ use std::map::hashmap;
type header_map = hashmap<~str, @DVec<@~str>>;
// the unused ty param is necessary so this gets monomorphized
fn request<T: copy>(req: header_map) {
fn request<T: Copy>(req: header_map) {
let _x = *(*req.get(~"METHOD"))[0u];
}

View File

@ -25,7 +25,7 @@ impl bool: read {
}
}
fn read<T: read copy>(s: ~str) -> T {
fn read<T: read Copy>(s: ~str) -> T {
match readMaybe(s) {
Some(x) => x,
_ => fail ~"read failed!"

View File

@ -18,16 +18,16 @@ export recv;
* transmitted. If a port value is copied, both copies refer to the same
* port. Ports may be associated with multiple `chan`s.
*/
enum port<T: send> {
enum port<T: Send> {
port_t(@port_ptr<T>)
}
/// Constructs a port
fn port<T: send>() -> port<T> {
fn port<T: Send>() -> port<T> {
port_t(@port_ptr(rustrt::new_port(sys::size_of::<T>() as size_t)))
}
struct port_ptr<T:send> {
struct port_ptr<T:Send> {
po: *rust_port,
drop unsafe {
debug!("in the port_ptr destructor");
@ -48,7 +48,7 @@ struct port_ptr<T:send> {
}
}
fn port_ptr<T: send>(po: *rust_port) -> port_ptr<T> {
fn port_ptr<T: Send>(po: *rust_port) -> port_ptr<T> {
debug!("in the port_ptr constructor");
port_ptr {
po: po
@ -59,11 +59,11 @@ fn port_ptr<T: send>(po: *rust_port) -> port_ptr<T> {
* Receive from a port. If no data is available on the port then the
* task will block until data becomes available.
*/
fn recv<T: send>(p: port<T>) -> T { recv_((**p).po) }
fn recv<T: Send>(p: port<T>) -> T { recv_((**p).po) }
/// Receive on a raw port pointer
fn recv_<T: send>(p: *rust_port) -> T {
fn recv_<T: Send>(p: *rust_port) -> T {
let yield = 0u;
let yieldp = ptr::addr_of(yield);
let mut res;

View File

@ -64,7 +64,7 @@ macro_rules! follow (
)
)
fn switch<T: send, Tb: send, U>(+endp: pipes::RecvPacketBuffered<T, Tb>,
fn switch<T: Send, Tb: Send, U>(+endp: pipes::RecvPacketBuffered<T, Tb>,
f: fn(+Option<T>) -> U) -> U {
f(pipes::try_recv(endp))
}

View File

@ -15,14 +15,14 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {
return (xx as float) * 100f / (yy as float);
}
pure fn le_by_val<TT: copy, UU: copy>(kv0: &(TT,UU),
pure fn le_by_val<TT: Copy, UU: Copy>(kv0: &(TT,UU),
kv1: &(TT,UU)) -> bool {
let (_, v0) = *kv0;
let (_, v1) = *kv1;
return v0 >= v1;
}
pure fn le_by_key<TT: copy, UU: copy>(kv0: &(TT,UU),
pure fn le_by_key<TT: Copy, UU: Copy>(kv0: &(TT,UU),
kv1: &(TT,UU)) -> bool {
let (k0, _) = *kv0;
let (k1, _) = *kv1;
@ -30,7 +30,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {
}
// sort by key, then by value
fn sortKV<TT: copy, UU: copy>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
fn sortKV<TT: Copy, UU: Copy>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
return sort::merge_sort(le_by_val, sort::merge_sort(le_by_key, orig));
}

View File

@ -14,14 +14,14 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {
return (xx as float) * 100f / (yy as float);
}
pure fn le_by_val<TT: copy, UU: copy>(kv0: &(TT,UU),
pure fn le_by_val<TT: Copy, UU: Copy>(kv0: &(TT,UU),
kv1: &(TT,UU)) -> bool {
let (_, v0) = *kv0;
let (_, v1) = *kv1;
return v0 >= v1;
}
pure fn le_by_key<TT: copy, UU: copy>(kv0: &(TT,UU),
pure fn le_by_key<TT: Copy, UU: Copy>(kv0: &(TT,UU),
kv1: &(TT,UU)) -> bool {
let (k0, _) = *kv0;
let (k1, _) = *kv1;
@ -29,7 +29,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {
}
// sort by key, then by value
fn sortKV<TT: copy, UU: copy>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
fn sortKV<TT: Copy, UU: Copy>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
return sort::merge_sort(le_by_val, sort::merge_sort(le_by_key, orig));
}

View File

@ -39,9 +39,9 @@ trait hash_key {
pure fn eq(&&k: self) -> bool;
}
fn mk_hash<K: const hash_key, V: copy>() -> map::hashmap<K, V> {
pure fn hashfn<K: const hash_key>(k: &K) -> uint { k.hash() }
pure fn hasheq<K: const hash_key>(k1: &K, k2: &K) -> bool { k1.eq(*k2) }
fn mk_hash<K: Const hash_key, V: Copy>() -> map::hashmap<K, V> {
pure fn hashfn<K: Const hash_key>(k: &K) -> uint { k.hash() }
pure fn hasheq<K: Const hash_key>(k1: &K, k2: &K) -> bool { k1.eq(*k2) }
map::hashmap(hashfn, hasheq)
}
@ -125,35 +125,35 @@ mod map_reduce {
export reducer;
export map_reduce;
type putter<K: send, V: send> = fn(K, V);
type putter<K: Send, V: Send> = fn(K, V);
type mapper<K1: send, K2: send, V: send> = fn~(K1, putter<K2, V>);
type mapper<K1: Send, K2: Send, V: Send> = fn~(K1, putter<K2, V>);
type getter<V: send> = fn() -> Option<V>;
type getter<V: Send> = fn() -> Option<V>;
type reducer<K: copy send, V: copy send> = fn~(K, getter<V>);
type reducer<K: Copy Send, V: Copy Send> = fn~(K, getter<V>);
enum ctrl_proto<K: copy send, V: copy send> {
enum ctrl_proto<K: Copy Send, V: Copy Send> {
find_reducer(K, Chan<Chan<reduce_proto<V>>>),
mapper_done
}
proto! ctrl_proto (
open: send<K: copy send, V: copy send> {
open: send<K: Copy Send, V: Copy Send> {
find_reducer(K) -> reducer_response<K, V>,
mapper_done -> !
}
reducer_response: recv<K: copy send, V: copy send> {
reducer_response: recv<K: Copy Send, V: Copy Send> {
reducer(Chan<reduce_proto<V>>) -> open<K, V>
}
)
enum reduce_proto<V: copy send> { emit_val(V), done, addref, release }
enum reduce_proto<V: Copy Send> { emit_val(V), done, addref, release }
fn start_mappers<K1: copy send, K2: const copy send hash_key,
V: copy send>(
fn start_mappers<K1: Copy Send, K2: Const Copy Send hash_key,
V: Copy Send>(
map: mapper<K1, K2, V>,
&ctrls: ~[ctrl_proto::server::open<K2, V>],
inputs: ~[K1])
@ -169,7 +169,7 @@ mod map_reduce {
return tasks;
}
fn map_task<K1: copy send, K2: const copy send hash_key, V: copy send>(
fn map_task<K1: Copy Send, K2: Const Copy Send hash_key, V: Copy Send>(
map: mapper<K1, K2, V>,
ctrl: box<ctrl_proto::client::open<K2, V>>,
input: K1)
@ -198,7 +198,7 @@ mod map_reduce {
send(c.get(), emit_val(val));
}
fn finish<K: copy send, V: copy send>(_k: K, v: Chan<reduce_proto<V>>)
fn finish<K: Copy Send, V: Copy Send>(_k: K, v: Chan<reduce_proto<V>>)
{
send(v, release);
}
@ -206,7 +206,7 @@ mod map_reduce {
ctrl_proto::client::mapper_done(ctrl.unwrap());
}
fn reduce_task<K: copy send, V: copy send>(
fn reduce_task<K: Copy Send, V: Copy Send>(
reduce: reducer<K, V>,
key: K,
out: Chan<Chan<reduce_proto<V>>>)
@ -218,7 +218,7 @@ mod map_reduce {
let mut ref_count = 0;
let mut is_done = false;
fn get<V: copy send>(p: Port<reduce_proto<V>>,
fn get<V: Copy Send>(p: Port<reduce_proto<V>>,
&ref_count: int, &is_done: bool)
-> Option<V> {
while !is_done || ref_count > 0 {
@ -241,7 +241,7 @@ mod map_reduce {
reduce(key, || get(p, ref_count, is_done) );
}
fn map_reduce<K1: copy send, K2: const copy send hash_key, V: copy send>(
fn map_reduce<K1: Copy Send, K2: Const Copy Send hash_key, V: Copy Send>(
map: mapper<K1, K2, V>,
reduce: reducer<K2, V>,
inputs: ~[K1])

View File

@ -3,11 +3,11 @@ fn foo<T>() {
}
trait bar {
fn bar<T:copy>();
fn bar<T:Copy>();
}
impl uint: bar {
fn bar<T:copy>() {
fn bar<T:Copy>() {
}
}

View File

@ -1,4 +1,4 @@
fn reproduce<T:copy>(t: T) -> fn@() -> T {
fn reproduce<T:Copy>(t: T) -> fn@() -> T {
fn@() -> T { t }
}

View File

@ -1,4 +1,4 @@
fn mk_identity<T:copy>() -> fn@(T) -> T {
fn mk_identity<T:Copy>() -> fn@(T) -> T {
fn@(t: T) -> T { t }
}

View File

@ -11,7 +11,7 @@ impl uint: to_opt {
}
}
impl<T:copy> Option<T>: to_opt {
impl<T:Copy> Option<T>: to_opt {
fn to_option() -> Option<Option<T>> {
Some(self)
}

View File

@ -1,4 +1,4 @@
fn foo<T: copy>(+_t: T) { fail; }
fn foo<T: Copy>(+_t: T) { fail; }
fn bar<T>(+_t: T) { fail; }

View File

@ -7,7 +7,7 @@ import iter;
import iter::BaseIter;
trait A {
fn b<C:copy const, D>(x: C) -> C;
fn b<C:Copy Const, D>(x: C) -> C;
}
struct E {
@ -15,7 +15,7 @@ struct E {
}
impl E: A {
fn b<F:copy, G>(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 1 bound, but
fn b<F:Copy, G>(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 1 bound, but
}
fn main() {}

View File

@ -4,7 +4,7 @@ import iter;
import iter::BaseIter;
trait A {
fn b<C:copy, D>(x: C) -> C;
fn b<C:Copy, D>(x: C) -> C;
}
struct E {
@ -12,7 +12,7 @@ struct E {
}
impl E: A {
fn b<F:copy const, G>(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but
fn b<F:Copy Const, G>(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but
}
fn main() {}

View File

@ -4,7 +4,7 @@ import iter;
import iter::BaseIter;
trait A {
fn b<C:copy, D>(x: C) -> C;
fn b<C:Copy, D>(x: C) -> C;
}
struct E {
@ -13,7 +13,7 @@ struct E {
impl E: A {
// n.b. The error message is awful -- see #3404
fn b<F:copy, G>(_x: G) -> G { fail } //~ ERROR method `b` has an incompatible type
fn b<F:Copy, G>(_x: G) -> G { fail } //~ ERROR method `b` has an incompatible type
}
fn main() {}

View File

@ -1,4 +1,4 @@
struct send_packet<T: copy> {
struct send_packet<T: Copy> {
p: T
}

View File

@ -1,7 +1,7 @@
mod stream {
enum stream<T: send> { send(T, server::stream<T>), }
enum stream<T: Send> { send(T, server::stream<T>), }
mod server {
impl<T: send> stream<T> {
impl<T: Send> stream<T> {
fn recv() -> extern fn(+stream<T>) -> stream::stream<T> {
// resolve really should report just one error here.
// Change the test case when it changes.
@ -14,7 +14,7 @@ mod stream {
recv
}
}
type stream<T: send> = pipes::RecvPacket<stream::stream<T>>;
type stream<T: Send> = pipes::RecvPacket<stream::stream<T>>;
}
}

View File

@ -1,10 +1,10 @@
trait repeat<A> { fn get() -> A; }
impl<A:copy> @A: repeat<A> {
impl<A:Copy> @A: repeat<A> {
fn get() -> A { *self }
}
fn repeater<A:copy>(v: @A) -> repeat<A> {
fn repeater<A:Copy>(v: @A) -> repeat<A> {
// Note: owned kind is not necessary as A appears in the trait type
v as repeat::<A> // No
}

View File

@ -5,11 +5,11 @@ trait foo {
fn foo(i: &self/int) -> int;
}
impl<T:copy> T: foo {
impl<T:Copy> T: foo {
fn foo(i: &self/int) -> int {*i}
}
fn to_foo<T:copy>(t: T) {
fn to_foo<T:Copy>(t: T) {
// This version is ok because, although T may contain borrowed
// pointers, it never escapes the fn body. We know this because
// the type of foo includes a region which will be resolved to
@ -19,13 +19,13 @@ fn to_foo<T:copy>(t: T) {
assert x.foo(v) == 3;
}
fn to_foo_2<T:copy>(t: T) -> foo {
fn to_foo_2<T:Copy>(t: T) -> foo {
// Not OK---T may contain borrowed ptrs and it is going to escape
// as part of the returned foo value
{f:t} as foo //~ ERROR value may contain borrowed pointers; use `owned` bound
}
fn to_foo_3<T:copy owned>(t: T) -> foo {
fn to_foo_3<T:Copy Owned>(t: T) -> foo {
// OK---T may escape as part of the returned foo value, but it is
// owned and hence does not contain borrowed ptrs
{f:t} as foo

View File

@ -1,10 +1,10 @@
trait foo { fn foo(); }
fn to_foo<T: copy foo>(t: T) -> foo {
fn to_foo<T: Copy foo>(t: T) -> foo {
t as foo //~ ERROR value may contain borrowed pointers; use `owned` bound
}
fn to_foo2<T: copy foo owned>(t: T) -> foo {
fn to_foo2<T: Copy foo Owned>(t: T) -> foo {
t as foo
}

View File

@ -1,8 +1,8 @@
fn copy1<T: copy>(t: T) -> fn@() -> T {
fn copy1<T: Copy>(t: T) -> fn@() -> T {
fn@() -> T { t } //~ ERROR value may contain borrowed pointers
}
fn copy2<T: copy owned>(t: T) -> fn@() -> T {
fn copy2<T: Copy Owned>(t: T) -> fn@() -> T {
fn@() -> T { t }
}

View File

@ -1,4 +1,4 @@
fn send<T: send>(ch: _chan<T>, -data: T) {
fn send<T: Send>(ch: _chan<T>, -data: T) {
log(debug, ch);
log(debug, data);
fail;

View File

@ -1,6 +1,6 @@
// Test that various non const things are rejected.
fn foo<T: const>(_x: T) { }
fn foo<T: Const>(_x: T) { }
struct r {
x:int,

View File

@ -5,7 +5,7 @@
use core;
fn last<T: copy>(v: ~[const T]) -> core::Option<T> {
fn last<T: Copy>(v: ~[const T]) -> core::Option<T> {
fail;
}

View File

@ -7,7 +7,7 @@ enum box_impl<T> = {
mut f: T
};
impl<T:copy> box_impl<T>: box_trait<T> {
impl<T:Copy> box_impl<T>: box_trait<T> {
fn get() -> T { return self.f; }
fn set(t: T) { self.f = t; }
}

View File

@ -1,4 +1,4 @@
fn f<T: send>(_i: T) {
fn f<T: Send>(_i: T) {
}
fn main() {

View File

@ -1,4 +1,4 @@
fn concat<T: copy>(v: ~[const ~[const T]]) -> ~[T] {
fn concat<T: Copy>(v: ~[const ~[const T]]) -> ~[T] {
let mut r = ~[];
// Earlier versions of our type checker accepted this:

View File

@ -4,8 +4,8 @@ fn test00_start(ch: chan_t<int>, message: int) { send(ch, message); }
type task_id = int;
type port_id = int;
enum chan_t<T: send> = {task: task_id, port: port_id};
enum chan_t<T: Send> = {task: task_id, port: port_id};
fn send<T: send>(ch: chan_t<T>, data: T) { fail; }
fn send<T: Send>(ch: chan_t<T>, data: T) { fail; }
fn main() { fail ~"quux"; }

View File

@ -3,7 +3,7 @@
use std;
use std::arc;
enum e<T: const send> { e(arc::ARC<T>) }
enum e<T: Const Send> { e(arc::ARC<T>) }
fn foo() -> e<int> {fail;}

View File

@ -5,7 +5,7 @@ use comm::Port;
use comm::send;
use comm::recv;
fn echo<T: send>(c: Chan<T>, oc: Chan<Chan<T>>) {
fn echo<T: Send>(c: Chan<T>, oc: Chan<Chan<T>>) {
// Tests that the type argument in port gets
// visited
let p = Port::<T>();

View File

@ -2,7 +2,7 @@ type pair<A,B> = {
a: A, b: B
};
fn f<A:copy owned>(a: A, b: u16) -> fn@() -> (A, u16) {
fn f<A:Copy Owned>(a: A, b: u16) -> fn@() -> (A, u16) {
fn@() -> (A, u16) { (a, b) }
}

Some files were not shown because too many files have changed in this diff Show More