about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-01-05 15:35:37 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-01-05 15:50:02 +0100
commit60ae1590af034755b5cb1e1e71f2240a710299a2 (patch)
tree605d11f071a776c0ca33dcfea0a774379b0880bb /src/libcore
parent1f71a0f48d18d80ff3be6970d582c5a67f976329 (diff)
downloadrust-60ae1590af034755b5cb1e1e71f2240a710299a2.tar.gz
rust-60ae1590af034755b5cb1e1e71f2240a710299a2.zip
Switch to new param kind bound syntax
And remove support for the old syntax
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/comm.rs20
-rw-r--r--src/libcore/either.rs10
-rw-r--r--src/libcore/float.rs4
-rw-r--r--src/libcore/option.rs8
-rw-r--r--src/libcore/result.rs8
-rw-r--r--src/libcore/task.rs10
-rw-r--r--src/libcore/vec.rs58
7 files changed, 59 insertions, 59 deletions
diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs
index e00205a522b..d8051dfabd1 100644
--- a/src/libcore/comm.rs
+++ b/src/libcore/comm.rs
@@ -39,7 +39,7 @@ native mod rustrt {
     type void;
     type rust_port;
 
-    fn chan_id_send<send T>(t: *sys::type_desc,
+    fn chan_id_send<T: send>(t: *sys::type_desc,
                             target_task: task::task, target_port: port_id,
                             data: T) -> ctypes::uintptr_t;
 
@@ -55,7 +55,7 @@ native mod rustrt {
 
 #[abi = "rust-intrinsic"]
 native mod rusti {
-    fn call_with_retptr<send T>(&&f: fn@(*uint)) -> T;
+    fn call_with_retptr<T: send>(&&f: fn@(*uint)) -> T;
 }
 
 type port_id = int;
@@ -78,11 +78,11 @@ dropped.
 
 Channels may be duplicated and themselves transmitted over other channels.
 */
-tag chan<send T> {
+tag chan<T: send> {
     chan_t(task::task, port_id);
 }
 
-resource port_ptr<send T>(po: *rustrt::rust_port) {
+resource port_ptr<T: send>(po: *rustrt::rust_port) {
     // Once the port is detached it's guaranteed not to receive further
     // messages
     rustrt::rust_port_detach(po);
@@ -106,7 +106,7 @@ transmitted. If a port value is copied, both copies refer to the same port.
 
 Ports may be associated with multiple <chan>s.
 */
-tag port<send T> { port_t(@port_ptr<T>); }
+tag port<T: send> { port_t(@port_ptr<T>); }
 
 /*
 Function: send
@@ -116,7 +116,7 @@ Sends data over a channel.
 The sent data is moved into the channel, whereupon the caller loses access
 to it.
 */
-fn send<send T>(ch: chan<T>, -data: T) {
+fn send<T: send>(ch: chan<T>, -data: T) {
     let chan_t(t, p) = ch;
     let res = rustrt::chan_id_send(sys::get_type_desc::<T>(), t, p, data);
     if res != 0u unsafe {
@@ -131,7 +131,7 @@ Function: port
 
 Constructs a port.
 */
-fn port<send T>() -> port<T> {
+fn port<T: send>() -> port<T> {
     port_t(@port_ptr(rustrt::new_port(sys::size_of::<T>())))
 }
 
@@ -143,10 +143,10 @@ Receive from a port.
 If no data is available on the port then the task will block until data
 becomes available.
 */
-fn recv<send T>(p: port<T>) -> T { recv_(***p) }
+fn recv<T: send>(p: port<T>) -> T { recv_(***p) }
 
 // Receive on a raw port pointer
-fn recv_<send T>(p: *rustrt::rust_port) -> T {
+fn recv_<T: send>(p: *rustrt::rust_port) -> T {
     // FIXME: Due to issue 1185 we can't use a return pointer when
     // calling C code, and since we can't create our own return
     // pointer on the stack, we're going to call a little intrinsic
@@ -179,6 +179,6 @@ Constructs a channel.
 
 The channel is bound to the port used to construct it.
 */
-fn chan<send T>(p: port<T>) -> chan<T> {
+fn chan<T: send>(p: port<T>) -> chan<T> {
     chan_t(task::get_task(), rustrt::get_port_id(***p))
 }
diff --git a/src/libcore/either.rs b/src/libcore/either.rs
index f3571ea5bcf..e6956930686 100644
--- a/src/libcore/either.rs
+++ b/src/libcore/either.rs
@@ -39,7 +39,7 @@ Function: lefts
 
 Extracts from a vector of either all the left values.
 */
-fn lefts<copy T, U>(eithers: [t<T, U>]) -> [T] {
+fn lefts<T: copy, U>(eithers: [t<T, U>]) -> [T] {
     let result: [T] = [];
     for elt: t<T, U> in eithers {
         alt elt { left(l) { result += [l]; } _ {/* fallthrough */ } }
@@ -52,7 +52,7 @@ Function: rights
 
 Extracts from a vector of either all the right values
 */
-fn rights<T, copy U>(eithers: [t<T, U>]) -> [U] {
+fn rights<T, U: copy>(eithers: [t<T, U>]) -> [U] {
     let result: [U] = [];
     for elt: t<T, U> in eithers {
         alt elt { right(r) { result += [r]; } _ {/* fallthrough */ } }
@@ -68,7 +68,7 @@ Extracts from a vector of either all the left values and right values
 Returns a structure containing a vector of left values and a vector of
 right values.
 */
-fn partition<copy T, copy U>(eithers: [t<T, U>])
+fn partition<T: copy, U: copy>(eithers: [t<T, U>])
     -> {lefts: [T], rights: [U]} {
     let lefts: [T] = [];
     let rights: [U] = [];
@@ -83,7 +83,7 @@ Function: flip
 
 Flips between left and right of a given either
 */
-pure fn flip<copy T, copy U>(eith: t<T, U>) -> t<U, T> {
+pure fn flip<T: copy, U: copy>(eith: t<T, U>) -> t<U, T> {
     alt eith {
       right(r) { left(r) }
       left(l) { right(l) }
@@ -96,7 +96,7 @@ Function: to_result
 Converts either::t to a result::t, making the "right" choice
 an ok result, and the "left" choice a fail
 */
-pure fn to_result<copy T, copy U>(eith: t<T, U>) -> result::t<U, T> {
+pure fn to_result<T: copy, U: copy>(eith: t<T, U>) -> result::t<U, T> {
     alt eith {
       right(r) { result::ok(r) }
       left(l) { result::err(l) }
diff --git a/src/libcore/float.rs b/src/libcore/float.rs
index fdc5dda996d..dcc44b36605 100644
--- a/src/libcore/float.rs
+++ b/src/libcore/float.rs
@@ -467,14 +467,14 @@ Function: min
 
 Returns the minimum of two values
 */
-pure fn min<copy T>(x: T, y: T) -> T { x < y ? x : y }
+pure fn min<T: copy>(x: T, y: T) -> T { x < y ? x : y }
 
 /*
 Function: max
 
 Returns the maximum of two values
 */
-pure fn max<copy T>(x: T, y: T) -> T { x < y ? y : x }
+pure fn max<T: copy>(x: T, y: T) -> T { x < y ? y : x }
 
 /*
 Function: acos
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index e0a137ca9e8..453f38567a8 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -30,13 +30,13 @@ Failure:
 
 Fails if the value equals `none`.
 */
-pure fn get<copy T>(opt: t<T>) -> T {
+pure fn get<T: copy>(opt: t<T>) -> T {
     alt opt { some(x) { ret x; } none. { fail "option none"; } }
 }
 
 /*
 */
-fn map<T, copy U>(opt: t<T>, f: block(T) -> U) -> t<U> {
+fn map<T, U: copy>(opt: t<T>, f: block(T) -> U) -> t<U> {
     alt opt { some(x) { some(f(x)) } none. { none } }
 }
 
@@ -61,7 +61,7 @@ Function: from_maybe
 
 Returns the contained value or a default
 */
-pure fn from_maybe<copy T>(def: T, opt: t<T>) -> T {
+pure fn from_maybe<T: copy>(def: T, opt: t<T>) -> T {
     alt opt { some(x) { x } none. { def } }
 }
 
@@ -70,7 +70,7 @@ Function: maybe
 
 Applies a function to the contained value or returns a default
 */
-fn maybe<T, copy U>(def: U, opt: t<T>, f: block(T) -> U) -> U {
+fn maybe<T, U: copy>(def: U, opt: t<T>, f: block(T) -> U) -> U {
     alt opt { none. { def } some(t) { f(t) } }
 }
 
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 91038474ead..52af0421e58 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -37,7 +37,7 @@ Failure:
 
 If the result is an error
 */
-fn get<copy T, U>(res: t<T, U>) -> T {
+fn get<T: copy, U>(res: t<T, U>) -> T {
     alt res {
       ok(t) { t }
       err(_) {
@@ -57,7 +57,7 @@ Failure:
 
 If the result is not an error
 */
-fn get_err<T, copy U>(res: t<T, U>) -> U {
+fn get_err<T, U: copy>(res: t<T, U>) -> U {
     alt res {
       err(u) { u }
       ok(_) {
@@ -87,7 +87,7 @@ pure fn failure<T, U>(res: t<T, U>) -> bool {
     !success(res)
 }
 
-pure fn to_either<copy T, copy U>(res: t<U, T>) -> either::t<T, U> {
+pure fn to_either<T: copy, U: copy>(res: t<U, T>) -> either::t<T, U> {
     alt res {
       ok(res) { either::right(res) }
       err(fail_) { either::left(fail_) }
@@ -110,7 +110,7 @@ Example:
 > })
 
 */
-fn chain<T, copy U, copy V>(res: t<T, V>, op: block(T) -> t<U, V>)
+fn chain<T, U: copy, V: copy>(res: t<T, V>, op: block(T) -> t<U, V>)
     -> t<U, V> {
     alt res {
       ok(t) { op(t) }
diff --git a/src/libcore/task.rs b/src/libcore/task.rs
index 503a336f7cd..5de9c8347fe 100644
--- a/src/libcore/task.rs
+++ b/src/libcore/task.rs
@@ -236,7 +236,7 @@ Returns:
 
 A handle to the new task
 */
-fn spawn<send T>(-data: T, f: fn(T)) -> task {
+fn spawn<T: send>(-data: T, f: fn(T)) -> task {
     spawn_inner(data, f, none)
 }
 
@@ -249,7 +249,7 @@ termination
 Immediately before termination, either on success or failure, the spawned
 task will send a <task_notification> message on the provided channel.
 */
-fn spawn_notify<send T>(-data: T, f: fn(T),
+fn spawn_notify<T: send>(-data: T, f: fn(T),
                          notify: comm::chan<task_notification>) -> task {
     spawn_inner(data, f, some(notify))
 }
@@ -263,7 +263,7 @@ This is a convenience wrapper around spawn_notify which, when paired
 with <join> can be easily used to spawn a task then wait for it to
 complete.
 */
-fn spawn_joinable<send T>(-data: T, f: fn(T)) -> joinable_task {
+fn spawn_joinable<T: send>(-data: T, f: fn(T)) -> joinable_task {
     let p = comm::port::<task_notification>();
     let id = spawn_notify(data, f, comm::chan::<task_notification>(p));
     ret (id, p);
@@ -279,11 +279,11 @@ fn spawn_joinable<send T>(-data: T, f: fn(T)) -> joinable_task {
 //
 // After the transition this should all be rewritten.
 
-fn spawn_inner<send T>(-data: T, f: fn(T),
+fn spawn_inner<T: send>(-data: T, f: fn(T),
                           notify: option<comm::chan<task_notification>>)
     -> task unsafe {
 
-    fn wrapper<send T>(data: *u8, f: fn(T)) unsafe {
+    fn wrapper<T: send>(data: *u8, f: fn(T)) unsafe {
         let data: ~T = unsafe::reinterpret_cast(data);
         f(*data);
     }
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs
index 0c1db7119af..32bb2f46a49 100644
--- a/src/libcore/vec.rs
+++ b/src/libcore/vec.rs
@@ -121,7 +121,7 @@ Creates and initializes an immutable vector.
 Creates an immutable vector of size `n_elts` and initializes the elements
 to the value `t`.
 */
-fn init_elt<copy T>(t: T, n_elts: uint) -> [T] {
+fn init_elt<T: copy>(t: T, n_elts: uint) -> [T] {
     let v = [];
     reserve(v, n_elts);
     let i: uint = 0u;
@@ -138,7 +138,7 @@ Creates and initializes a mutable vector.
 Creates a mutable vector of size `n_elts` and initializes the elements
 to the value `t`.
 */
-fn init_elt_mut<copy T>(t: T, n_elts: uint) -> [mutable T] {
+fn init_elt_mut<T: copy>(t: T, n_elts: uint) -> [mutable T] {
     let v = [mutable];
     reserve(v, n_elts);
     let i: uint = 0u;
@@ -153,7 +153,7 @@ Function: to_mut
 
 Produces a mutable vector from an immutable vector.
 */
-fn to_mut<copy T>(v: [T]) -> [mutable T] {
+fn to_mut<T: copy>(v: [T]) -> [mutable T] {
     let vres = [mutable];
     for t: T in v { vres += [mutable t]; }
     ret vres;
@@ -165,7 +165,7 @@ Function: from_mut
 
 Produces an immutable vector from a mutable vector.
 */
-fn from_mut<copy T>(v: [mutable T]) -> [T] {
+fn from_mut<T: copy>(v: [mutable T]) -> [T] {
     let vres = [];
     for t: T in v { vres += [t]; }
     ret vres;
@@ -181,7 +181,7 @@ Returns the first element of a vector
 Predicates:
 <is_not_empty> (v)
 */
-pure fn head<copy T>(v: [const T]) : is_not_empty(v) -> T { ret v[0]; }
+pure fn head<T: copy>(v: [const T]) : is_not_empty(v) -> T { ret v[0]; }
 
 /*
 Function: tail
@@ -191,7 +191,7 @@ Returns all but the first element of a vector
 Predicates:
 <is_not_empty> (v)
 */
-fn tail<copy T>(v: [const T]) : is_not_empty(v) -> [T] {
+fn tail<T: copy>(v: [const T]) : is_not_empty(v) -> [T] {
     ret slice(v, 1u, len(v));
 }
 
@@ -206,7 +206,7 @@ Returns all but the last elemnt of a vector
 Preconditions:
 `v` is not empty
 */
-fn init<copy T>(v: [const T]) -> [T] {
+fn init<T: copy>(v: [const T]) -> [T] {
     assert len(v) != 0u;
     slice(v, 0u, len(v) - 1u)
 }
@@ -221,7 +221,7 @@ Returns:
 An option containing the last element of `v` if `v` is not empty, or
 none if `v` is empty.
 */
-pure fn last<copy T>(v: [const T]) -> option::t<T> {
+pure fn last<T: copy>(v: [const T]) -> option::t<T> {
     if len(v) == 0u { ret none; }
     ret some(v[len(v) - 1u]);
 }
@@ -234,7 +234,7 @@ Returns the last element of a non-empty vector `v`
 Predicates:
 <is_not_empty> (v)
 */
-pure fn last_total<copy T>(v: [const T]) : is_not_empty(v) -> T {
+pure fn last_total<T: copy>(v: [const T]) : is_not_empty(v) -> T {
     ret v[len(v) - 1u];
 }
 
@@ -243,7 +243,7 @@ Function: slice
 
 Returns a copy of the elements from [`start`..`end`) from `v`.
 */
-fn slice<copy T>(v: [const T], start: uint, end: uint) -> [T] {
+fn slice<T: copy>(v: [const T], start: uint, end: uint) -> [T] {
     assert (start <= end);
     assert (end <= len(v));
     let result = [];
@@ -259,7 +259,7 @@ Function: slice_mut
 
 Returns a copy of the elements from [`start`..`end`) from `v`.
 */
-fn slice_mut<copy T>(v: [const T], start: uint, end: uint) -> [mutable T] {
+fn slice_mut<T: copy>(v: [const T], start: uint, end: uint) -> [mutable T] {
     assert (start <= end);
     assert (end <= len(v));
     let result = [mutable];
@@ -277,7 +277,7 @@ Function: shift
 
 Removes the first element from a vector and return it
 */
-fn shift<copy T>(&v: [const T]) -> T {
+fn shift<T: copy>(&v: [const T]) -> T {
     let ln = len::<T>(v);
     assert (ln > 0u);
     let e = v[0];
@@ -291,7 +291,7 @@ Function: pop
 
 Remove the last element from a vector and return it
 */
-fn pop<copy T>(&v: [const T]) -> T {
+fn pop<T: copy>(&v: [const T]) -> T {
     let ln = len(v);
     assert (ln > 0u);
     ln -= 1u;
@@ -305,7 +305,7 @@ Function: push
 
 Append an element to a vector and return it
 */
-fn push<copy T>(&v: [T], initval: T) {
+fn push<T: copy>(&v: [T], initval: T) {
     grow(v, 1u, initval)
 }
 
@@ -325,7 +325,7 @@ v - The vector to grow
 n - The number of elements to add
 initval - The value for the new elements
 */
-fn grow<copy T>(&v: [T], n: uint, initval: T) {
+fn grow<T: copy>(&v: [T], n: uint, initval: T) {
     reserve(v, next_power_of_two(len(v) + n));
     let i: uint = 0u;
     while i < n { v += [initval]; i += 1u; }
@@ -344,7 +344,7 @@ v - The vector to grow
 n - The number of elements to add
 initval - The value for the new elements
 */
-fn grow_mut<copy T>(&v: [mutable T], n: uint, initval: T) {
+fn grow_mut<T: copy>(&v: [mutable T], n: uint, initval: T) {
     reserve(v, next_power_of_two(len(v) + n));
     let i: uint = 0u;
     while i < n { v += [mutable initval]; i += 1u; }
@@ -380,7 +380,7 @@ Sets the element at position `index` to `val`. If `index` is past the end
 of the vector, expands the vector by replicating `initval` to fill the
 intervening space.
 */
-fn grow_set<copy T>(&v: [mutable T], index: uint, initval: T, val: T) {
+fn grow_set<T: copy>(&v: [mutable T], index: uint, initval: T, val: T) {
     if index >= len(v) { grow_mut(v, index - len(v) + 1u, initval); }
     v[index] = val;
 }
@@ -405,7 +405,7 @@ Function: map_mut
 
 Apply a function to each element of a mutable vector and return the results
 */
-fn map_mut<copy T, U>(v: [const T], f: block(T) -> U) -> [U] {
+fn map_mut<T: copy, U>(v: [const T], f: block(T) -> U) -> [U] {
     let result = [];
     reserve(result, len(v));
     for elem: T in v {
@@ -420,7 +420,7 @@ Function: map2
 
 Apply a function to each pair of elements and return the results
 */
-fn map2<copy T, copy U, V>(v0: [T], v1: [U], f: block(T, U) -> V) -> [V] {
+fn map2<T: copy, U: copy, V>(v0: [T], v1: [U], f: block(T, U) -> V) -> [V] {
     let v0_len = len(v0);
     if v0_len != len(v1) { fail; }
     let u: [V] = [];
@@ -437,7 +437,7 @@ Apply a function to each element of a vector and return the results
 If function `f` returns `none` then that element is excluded from
 the resulting vector.
 */
-fn filter_map<copy T, copy U>(v: [const T], f: block(T) -> option::t<U>)
+fn filter_map<T: copy, U: copy>(v: [const T], f: block(T) -> option::t<U>)
     -> [U] {
     let result = [];
     for elem: T in v {
@@ -458,7 +458,7 @@ holds.
 Apply function `f` to each element of `v` and return a vector containing
 only those elements for which `f` returned true.
 */
-fn filter<copy T>(v: [T], f: block(T) -> bool) -> [T] {
+fn filter<T: copy>(v: [T], f: block(T) -> bool) -> [T] {
     let result = [];
     for elem: T in v {
         if f(elem) { result += [elem]; }
@@ -472,7 +472,7 @@ Function: concat
 Concatenate a vector of vectors. Flattens a vector of vectors of T into
 a single vector of T.
 */
-fn concat<copy T>(v: [const [const T]]) -> [T] {
+fn concat<T: copy>(v: [const [const T]]) -> [T] {
     let new: [T] = [];
     for inner: [T] in v { new += inner; }
     ret new;
@@ -483,7 +483,7 @@ Function: foldl
 
 Reduce a vector from left to right
 */
-fn foldl<copy T, U>(z: T, v: [const U], p: block(T, U) -> T) -> T {
+fn foldl<T: copy, U>(z: T, v: [const U], p: block(T, U) -> T) -> T {
     let accum = z;
     iter(v) { |elt|
         accum = p(accum, elt);
@@ -496,7 +496,7 @@ Function: foldr
 
 Reduce a vector from right to left
 */
-fn foldr<T, copy U>(v: [const T], z: U, p: block(T, U) -> U) -> U {
+fn foldr<T, U: copy>(v: [const T], z: U, p: block(T, U) -> U) -> U {
     let accum = z;
     riter(v) { |elt|
         accum = p(elt, accum);
@@ -591,7 +591,7 @@ Apply function `f` to each element of `v`, starting from the first.
 When function `f` returns true then an option containing the element
 is returned. If `f` matches no elements then none is returned.
 */
-fn find<copy T>(v: [T], f: block(T) -> bool) -> option::t<T> {
+fn find<T: copy>(v: [T], f: block(T) -> bool) -> option::t<T> {
     for elt: T in v { if f(elt) { ret some(elt); } }
     ret none;
 }
@@ -637,7 +637,7 @@ vector contains the first element of the i-th tuple of the input vector,
 and the i-th element of the second vector contains the second element
 of the i-th tuple of the input vector.
 */
-fn unzip<copy T, copy U>(v: [(T, U)]) -> ([T], [U]) {
+fn unzip<T: copy, U: copy>(v: [(T, U)]) -> ([T], [U]) {
     let as = [], bs = [];
     for (a, b) in v { as += [a]; bs += [b]; }
     ret (as, bs);
@@ -655,7 +655,7 @@ Preconditions:
 
 <same_length> (v, u)
 */
-fn zip<copy T, copy U>(v: [T], u: [U]) : same_length(v, u) -> [(T, U)] {
+fn zip<T: copy, U: copy>(v: [T], u: [U]) : same_length(v, u) -> [(T, U)] {
     let zipped = [];
     let sz = len(v), i = 0u;
     assert (sz == len(u));
@@ -694,7 +694,7 @@ Function: reversed
 
 Returns a vector with the order of elements reversed
 */
-fn reversed<copy T>(v: [const T]) -> [T] {
+fn reversed<T: copy>(v: [const T]) -> [T] {
     let rs: [T] = [];
     let i = len::<T>(v);
     if i == 0u { ret rs; } else { i -= 1u; }
@@ -805,7 +805,7 @@ is sorted then the permutations are lexicographically sorted).
 The total number of permutations produced is `len(v)!`.  If `v` contains
 repeated elements, then some permutations are repeated.
 */
-fn permute<copy T>(v: [const T], put: block([T])) {
+fn permute<T: copy>(v: [const T], put: block([T])) {
   let ln = len(v);
   if ln == 0u {
     put([]);