Skip to content

Commit 3bd1f32

Browse files
committed
Convert all kind bounds to camel case. Remove send, owned keywords.
1 parent 07fe561 commit 3bd1f32

File tree

167 files changed

+613
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+613
-622
lines changed

doc/rust.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ Two examples of paths with type arguments:
449449
~~~~
450450
# use std::map;
451451
# fn f() {
452-
# fn id<T:copy>(t: T) -> T { t }
452+
# fn id<T:Copy>(t: T) -> T { t }
453453
type t = map::hashmap<int,~str>; // Type arguments used in a type expression
454454
let x = id::<int>(10); // Type arguments used in a call expression
455455
# }
@@ -1056,7 +1056,7 @@ An example of a pure function that uses an unchecked block:
10561056
~~~~
10571057
# use std::list::*;
10581058
1059-
fn pure_foldl<T, U: copy>(ls: List<T>, u: U, f: fn(&&T, &&U) -> U) -> U {
1059+
fn pure_foldl<T, U: Copy>(ls: List<T>, u: U, f: fn(&&T, &&U) -> U) -> U {
10601060
match ls {
10611061
Nil => u,
10621062
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
11101110
parameter is given a [`copy` bound](#type-kinds).
11111111

11121112
~~~~
1113-
fn id<T: copy>(x: T) -> T { x }
1113+
fn id<T: Copy>(x: T) -> T { x }
11141114
~~~~
11151115

11161116
Similarly, [trait](#traits) bounds can be specified for type
@@ -2638,7 +2638,7 @@ Every struct item defines a type.
26382638
Within the body of an item that has type parameter declarations, the names of its type parameters are types:
26392639

26402640
~~~~~~~
2641-
fn map<A: copy, B: copy>(f: fn(A) -> B, xs: ~[A]) -> ~[B] {
2641+
fn map<A: Copy, B: Copy>(f: fn(A) -> B, xs: ~[A]) -> ~[B] {
26422642
if xs.len() == 0 { return ~[]; }
26432643
let first: B = f(xs[0]);
26442644
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
27062706
is assumed to be noncopyable. To change that, a bound is declared:
27072707

27082708
~~~~
2709-
fn box<T: copy>(x: T) -> @T { @x }
2709+
fn box<T: Copy>(x: T) -> @T { @x }
27102710
~~~~
27112711

27122712
Calling this second version of `box` on a noncopyable type is not

doc/tutorial.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1583,20 +1583,20 @@ unless you explicitly declare that type parameter to have copyable
15831583
// This does not compile
15841584
fn head_bad<T>(v: ~[T]) -> T { v[0] }
15851585
// This does
1586-
fn head<T: copy>(v: ~[T]) -> T { v[0] }
1586+
fn head<T: Copy>(v: ~[T]) -> T { v[0] }
15871587
~~~~
15881588

15891589
When instantiating a generic function, you can only instantiate it
15901590
with types that fit its kinds. So you could not apply `head` to a
15911591
resource type. Rust has several kinds that can be used as type bounds:
15921592

1593-
* `copy` - Copyable types. All types are copyable unless they
1593+
* `Copy` - Copyable types. All types are copyable unless they
15941594
are classes with destructors or otherwise contain
15951595
classes with destructors.
1596-
* `send` - Sendable types. All types are sendable unless they
1596+
* `Send` - Sendable types. All types are sendable unless they
15971597
contain shared boxes, closures, or other local-heap-allocated
15981598
types.
1599-
* `const` - Constant types. These are types that do not contain
1599+
* `Const` - Constant types. These are types that do not contain
16001600
mutable fields nor shared boxes.
16011601

16021602
> ***Note:*** Rust type kinds are syntactically very similar to
@@ -2002,7 +2002,7 @@ and one for values. This means that this code is valid:
20022002
~~~~
20032003
mod buffalo {
20042004
type buffalo = int;
2005-
fn buffalo<buffalo: copy>(buffalo: buffalo) -> buffalo { buffalo }
2005+
fn buffalo<buffalo>(+buffalo: buffalo) -> buffalo { buffalo }
20062006
}
20072007
fn main() {
20082008
let buffalo: buffalo::buffalo = 1;

src/fuzzer/fuzzer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: codemap::codemap,
239239
pprust::ty_to_str, replace_ty_in_crate, cx);
240240
}
241241

242-
fn check_variants_T<T: copy>(
242+
fn check_variants_T<T: Copy>(
243243
crate: ast::crate,
244244
codemap: codemap::codemap,
245245
filename: &Path,

src/libcore/at_vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pure fn build_sized_opt<A>(size: Option<uint>,
8989

9090
// Appending
9191
#[inline(always)]
92-
pure fn append<T: copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
92+
pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
9393
do build_sized(lhs.len() + rhs.len()) |push| {
9494
for vec::each(lhs) |x| { push(x); }
9595
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
@@ -125,15 +125,15 @@ pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
125125
* Creates an immutable vector of size `n_elts` and initializes the elements
126126
* to the value `t`.
127127
*/
128-
pure fn from_elem<T: copy>(n_elts: uint, t: T) -> @[T] {
128+
pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
129129
do build_sized(n_elts) |push| {
130130
let mut i: uint = 0u;
131131
while i < n_elts { push(t); i += 1u; }
132132
}
133133
}
134134

135135
#[cfg(notest)]
136-
impl<T: copy> @[T]: Add<&[const T],@[T]> {
136+
impl<T: Copy> @[T]: Add<&[const T],@[T]> {
137137
#[inline(always)]
138138
pure fn add(rhs: &[const T]) -> @[T] {
139139
append(self, rhs)

src/libcore/comm.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export listen;
4848
* transmitted. If a port value is copied, both copies refer to the same
4949
* port. Ports may be associated with multiple `chan`s.
5050
*/
51-
enum Port<T: send> {
51+
enum Port<T: Send> {
5252
Port_(@PortPtr<T>)
5353
}
5454

@@ -64,16 +64,16 @@ enum Port<T: send> {
6464
* data will be silently dropped. Channels may be duplicated and
6565
* themselves transmitted over other channels.
6666
*/
67-
enum Chan<T: send> {
67+
enum Chan<T: Send> {
6868
Chan_(port_id)
6969
}
7070

7171
/// Constructs a port
72-
fn Port<T: send>() -> Port<T> {
72+
fn Port<T: Send>() -> Port<T> {
7373
Port_(@PortPtr(rustrt::new_port(sys::size_of::<T>() as size_t)))
7474
}
7575

76-
impl<T: send> Port<T> {
76+
impl<T: Send> Port<T> {
7777

7878
fn chan() -> Chan<T> { Chan(self) }
7979
fn send(+v: T) { self.chan().send(v) }
@@ -82,7 +82,7 @@ impl<T: send> Port<T> {
8282

8383
}
8484

85-
impl<T: send> Chan<T> {
85+
impl<T: Send> Chan<T> {
8686

8787
fn chan() -> Chan<T> { self }
8888
fn send(+v: T) { send(self, v) }
@@ -92,12 +92,12 @@ impl<T: send> Chan<T> {
9292
}
9393

9494
/// Open a new receiving channel for the duration of a function
95-
fn listen<T: send, U>(f: fn(Chan<T>) -> U) -> U {
95+
fn listen<T: Send, U>(f: fn(Chan<T>) -> U) -> U {
9696
let po = Port();
9797
f(po.chan())
9898
}
9999

100-
struct PortPtr<T:send> {
100+
struct PortPtr<T:Send> {
101101
po: *rust_port,
102102
drop unsafe {
103103
do task::unkillable {
@@ -121,7 +121,7 @@ struct PortPtr<T:send> {
121121
}
122122
}
123123

124-
fn PortPtr<T: send>(po: *rust_port) -> PortPtr<T> {
124+
fn PortPtr<T: Send>(po: *rust_port) -> PortPtr<T> {
125125
PortPtr {
126126
po: po
127127
}
@@ -135,7 +135,7 @@ fn PortPtr<T: send>(po: *rust_port) -> PortPtr<T> {
135135
* Fails if the port is detached or dead. Fails if the port
136136
* is owned by a different task.
137137
*/
138-
fn as_raw_port<T: send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
138+
fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
139139

140140
struct PortRef {
141141
p: *rust_port,
@@ -167,15 +167,15 @@ fn as_raw_port<T: send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
167167
* Constructs a channel. The channel is bound to the port used to
168168
* construct it.
169169
*/
170-
fn Chan<T: send>(p: Port<T>) -> Chan<T> {
170+
fn Chan<T: Send>(p: Port<T>) -> Chan<T> {
171171
Chan_(rustrt::get_port_id((**p).po))
172172
}
173173

174174
/**
175175
* Sends data over a channel. The sent data is moved into the channel,
176176
* whereupon the caller loses access to it.
177177
*/
178-
fn send<T: send>(ch: Chan<T>, +data: T) {
178+
fn send<T: Send>(ch: Chan<T>, +data: T) {
179179
let Chan_(p) = ch;
180180
let data_ptr = ptr::addr_of(data) as *();
181181
let res = rustrt::rust_port_id_send(p, data_ptr);
@@ -190,22 +190,22 @@ fn send<T: send>(ch: Chan<T>, +data: T) {
190190
* Receive from a port. If no data is available on the port then the
191191
* task will block until data becomes available.
192192
*/
193-
fn recv<T: send>(p: Port<T>) -> T { recv_((**p).po) }
193+
fn recv<T: Send>(p: Port<T>) -> T { recv_((**p).po) }
194194

195195
/// Returns true if there are messages available
196-
fn peek<T: send>(p: Port<T>) -> bool { peek_((**p).po) }
196+
fn peek<T: Send>(p: Port<T>) -> bool { peek_((**p).po) }
197197

198198
#[doc(hidden)]
199-
fn recv_chan<T: send>(ch: comm::Chan<T>) -> T {
199+
fn recv_chan<T: Send>(ch: comm::Chan<T>) -> T {
200200
as_raw_port(ch, |x|recv_(x))
201201
}
202202

203-
fn peek_chan<T: send>(ch: comm::Chan<T>) -> bool {
203+
fn peek_chan<T: Send>(ch: comm::Chan<T>) -> bool {
204204
as_raw_port(ch, |x|peek_(x))
205205
}
206206

207207
/// Receive on a raw port pointer
208-
fn recv_<T: send>(p: *rust_port) -> T {
208+
fn recv_<T: Send>(p: *rust_port) -> T {
209209
let yield = 0u;
210210
let yieldp = ptr::addr_of(yield);
211211
let mut res;
@@ -231,7 +231,7 @@ fn peek_(p: *rust_port) -> bool {
231231
}
232232

233233
/// Receive on one of two ports
234-
fn select2<A: send, B: send>(p_a: Port<A>, p_b: Port<B>)
234+
fn select2<A: Send, B: Send>(p_a: Port<A>, p_b: Port<B>)
235235
-> Either<A, B> {
236236
let ports = ~[(**p_a).po, (**p_b).po];
237237
let yield = 0u, yieldp = ptr::addr_of(yield);

src/libcore/dlist.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pure fn from_elem<T>(+data: T) -> DList<T> {
9696
list
9797
}
9898

99-
fn from_vec<T: copy>(+vec: &[T]) -> DList<T> {
99+
fn from_vec<T: Copy>(+vec: &[T]) -> DList<T> {
100100
do vec::foldl(DList(), vec) |list,data| {
101101
list.push(data); // Iterating left-to-right -- add newly to the tail.
102102
list
@@ -417,7 +417,7 @@ impl<T> DList<T> {
417417
}
418418
}
419419

420-
impl<T: copy> DList<T> {
420+
impl<T: Copy> DList<T> {
421421
/// Remove data from the head of the list. O(1).
422422
fn pop() -> Option<T> { self.pop_n().map (|nobe| nobe.data) }
423423
/// Remove data from the tail of the list. O(1).

src/libcore/dvec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl<A> DVec<A> {
210210
}
211211
}
212212
213-
impl<A: copy> DVec<A> {
213+
impl<A: Copy> DVec<A> {
214214
/**
215215
* Append all elements of a vector to the end of the list
216216
*
@@ -327,7 +327,7 @@ impl<A: copy> DVec<A> {
327327
}
328328
}
329329

330-
impl<A:copy> DVec<A>: Index<uint,A> {
330+
impl<A:Copy> DVec<A>: Index<uint,A> {
331331
pure fn index(&&idx: uint) -> A {
332332
self.get_elt(idx)
333333
}

src/libcore/either.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn either<T, U, V>(f_left: fn((&T)) -> V,
2929
}
3030
}
3131

32-
fn lefts<T: copy, U>(eithers: &[Either<T, U>]) -> ~[T] {
32+
fn lefts<T: Copy, U>(eithers: &[Either<T, U>]) -> ~[T] {
3333
//! Extracts from a vector of either all the left values
3434
3535
let mut result: ~[T] = ~[];
@@ -42,7 +42,7 @@ fn lefts<T: copy, U>(eithers: &[Either<T, U>]) -> ~[T] {
4242
return result;
4343
}
4444

45-
fn rights<T, U: copy>(eithers: &[Either<T, U>]) -> ~[U] {
45+
fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
4646
//! Extracts from a vector of either all the right values
4747
4848
let mut result: ~[U] = ~[];
@@ -55,7 +55,7 @@ fn rights<T, U: copy>(eithers: &[Either<T, U>]) -> ~[U] {
5555
return result;
5656
}
5757

58-
fn partition<T: copy, U: copy>(eithers: &[Either<T, U>])
58+
fn partition<T: Copy, U: Copy>(eithers: &[Either<T, U>])
5959
-> {lefts: ~[T], rights: ~[U]} {
6060
/*!
6161
* 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>])
7575
return {lefts: lefts, rights: rights};
7676
}
7777

78-
pure fn flip<T: copy, U: copy>(eith: &Either<T, U>) -> Either<U, T> {
78+
pure fn flip<T: Copy, U: Copy>(eith: &Either<T, U>) -> Either<U, T> {
7979
//! Flips between left and right of a given either
8080
8181
match *eith {
@@ -84,7 +84,7 @@ pure fn flip<T: copy, U: copy>(eith: &Either<T, U>) -> Either<U, T> {
8484
}
8585
}
8686

87-
pure fn to_result<T: copy, U: copy>(eith: &Either<T, U>) -> Result<U, T> {
87+
pure fn to_result<T: Copy, U: Copy>(eith: &Either<T, U>) -> Result<U, T> {
8888
/*!
8989
* Converts either::t to a result::t
9090
*

src/libcore/future.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ priv enum FutureState<A> {
4343
}
4444

4545
/// Methods on the `future` type
46-
impl<A:copy> Future<A> {
46+
impl<A:Copy> Future<A> {
4747
fn get() -> A {
4848
//! Get the value of the future
4949
@@ -74,7 +74,7 @@ fn from_value<A>(+val: A) -> Future<A> {
7474
Future {state: Forced(val)}
7575
}
7676

77-
fn from_port<A:send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
77+
fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
7878
/*!
7979
* Create a future from a port
8080
*
@@ -105,7 +105,7 @@ fn from_fn<A>(+f: @fn() -> A) -> Future<A> {
105105
Future {state: Pending(f)}
106106
}
107107

108-
fn spawn<A:send>(+blk: fn~() -> A) -> Future<A> {
108+
fn spawn<A:Send>(+blk: fn~() -> A) -> Future<A> {
109109
/*!
110110
* Create a future from a unique closure.
111111
*
@@ -156,7 +156,7 @@ fn get_ref<A>(future: &r/Future<A>) -> &r/A {
156156
}
157157
}
158158

159-
fn get<A:copy>(future: &Future<A>) -> A {
159+
fn get<A:Copy>(future: &Future<A>) -> A {
160160
//! Get the value of the future
161161
162162
*get_ref(future)
@@ -169,7 +169,7 @@ fn with<A,B>(future: &Future<A>, blk: fn((&A)) -> B) -> B {
169169
}
170170

171171
proto! future_pipe (
172-
waiting:recv<T:send> {
172+
waiting:recv<T:Send> {
173173
completed(T) -> !
174174
}
175175
)

src/libcore/iter-trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
2828
}
2929
}
3030

31-
impl<A: copy> IMPL_T<A>: iter::CopyableIter<A> {
31+
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
3232
pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] {
3333
iter::filter_to_vec(self, pred)
3434
}
@@ -45,7 +45,7 @@ impl<A: copy> IMPL_T<A>: iter::CopyableIter<A> {
4545
pure fn find(p: fn(A) -> bool) -> Option<A> { iter::find(self, p) }
4646
}
4747

48-
impl<A: copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<A> {
48+
impl<A: Copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<A> {
4949
pure fn min() -> A { iter::min(self) }
5050
pure fn max() -> A { iter::max(self) }
5151
}

0 commit comments

Comments
 (0)