Skip to content

Commit 6a0720b

Browse files
committed
Convert impls to new syntax
1 parent e997948 commit 6a0720b

File tree

222 files changed

+503
-617
lines changed

Some content is hidden

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

222 files changed

+503
-617
lines changed

src/compiletest/errors.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import io::reader_util;
2-
31
import common::config;
42

53
export load_errors;

src/compiletest/header.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import option;
22
import str;
3-
import io::reader_util;
43

54
import common::config;
65

src/compiletest/procsrv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import run::spawn_process;
2-
import io::{writer_util, reader_util};
2+
import io::writer_util;
33
import libc::{c_int, pid_t};
44

55
import pipes::chan;

src/libcore/arc.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* share immutable data between tasks.
44
*/
55

6-
import sys::methods;
7-
86
export arc, get, clone;
97

108
export exclusive, methods;
@@ -96,7 +94,7 @@ fn exclusive<T:send >(-data: T) -> exclusive<T> {
9694
}
9795
}
9896

99-
impl methods<T: send> for exclusive<T> {
97+
impl<T: send> exclusive<T> {
10098
/// Duplicate an exclusive ARC. See arc::clone.
10199
fn clone() -> exclusive<T> {
102100
unsafe {
@@ -142,7 +140,6 @@ impl methods<T: send> for exclusive<T> {
142140
#[cfg(test)]
143141
mod tests {
144142
import comm::*;
145-
import future::extensions;
146143

147144
#[test]
148145
fn manually_share_arc() {

src/libcore/at_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ pure fn from_elem<T: copy>(n_elts: uint, t: T) -> @[T] {
123123
}
124124
}
125125

126-
impl extensions<T: copy> of vec_concat<T> for @[T] {
126+
impl<T: copy> @[T]: vec_concat<T> {
127127
#[inline(always)]
128128
pure fn +(rhs: &[const T]) -> @[T] {
129129
append(self, rhs)
130130
}
131131
}
132132

133133
#[cfg(notest)]
134-
impl extensions<T: copy> of add<&[const T],@[T]> for @[T] {
134+
impl<T: copy> @[T]: add<&[const T],@[T]> {
135135
#[inline(always)]
136136
pure fn add(rhs: &[const T]) -> @[T] {
137137
append(self, rhs)

src/libcore/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn port<T: send>() -> port<T> {
7070
port_t(@port_ptr(rustrt::new_port(sys::size_of::<T>() as size_t)))
7171
}
7272

73-
impl methods<T: send> for port<T> {
73+
impl<T: send> port<T> {
7474

7575
fn chan() -> chan<T> { chan(self) }
7676
fn send(+v: T) { self.chan().send(v) }
@@ -79,7 +79,7 @@ impl methods<T: send> for port<T> {
7979

8080
}
8181

82-
impl methods<T: send> for chan<T> {
82+
impl<T: send> chan<T> {
8383

8484
fn chan() -> chan<T> { self }
8585
fn send(+v: T) { send(self, v) }

src/libcore/core.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,13 @@
55
import option::{some, none};
66
import option = option::option;
77
import path = path::path;
8-
import tuple::{extensions, tuple_ops, extended_tuple_ops};
9-
import str::{extensions, str_slice, unique_str};
10-
import vec::extensions;
8+
import tuple::{tuple_ops, extended_tuple_ops};
9+
import str::{str_slice, unique_str};
1110
import vec::{const_vector, copyable_vector, immutable_vector};
1211
import vec::{immutable_copyable_vector, iter_trait_extensions, vec_concat};
1312
import iter::{base_iter, extended_iter, copyable_iter, times, timesi};
14-
import option::extensions;
15-
import option_iter::extensions;
16-
import ptr::{extensions, ptr};
17-
import rand::extensions;
18-
import result::extensions;
19-
import int::{num, times, timesi};
20-
import i8::{num, times, timesi};
21-
import i16::{num, times, timesi};
22-
import i32::{num, times, timesi};
23-
import i64::{num, times, timesi};
24-
import uint::{num, times, timesi};
25-
import u8::{num, times, timesi};
26-
import u16::{num, times, timesi};
27-
import u32::{num, times, timesi};
28-
import u64::{num, times, timesi};
29-
import float::num;
30-
import f32::num;
31-
import f64::num;
3213
import num::num;
14+
import ptr::ptr;
3315

3416
export path, option, some, none, unreachable;
3517
export extensions;

src/libcore/dlist.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
55
*/
66

7-
import dlist_iter::extensions;
8-
97
export dlist, dlist_node;
108
export new_dlist, from_elem, from_vec, extensions;
119

@@ -24,7 +22,7 @@ enum dlist<T> = @{
2422
mut tl: dlist_link<T>,
2523
};
2624

27-
impl private_methods<T> for dlist_node<T> {
25+
priv impl<T> dlist_node<T> {
2826
pure fn assert_links() {
2927
match self.next {
3028
some(neighbour) => match neighbour.prev {
@@ -47,7 +45,7 @@ impl private_methods<T> for dlist_node<T> {
4745
}
4846
}
4947

50-
impl extensions<T> for dlist_node<T> {
48+
impl<T> dlist_node<T> {
5149
/// Get the next node in the list, if there is one.
5250
pure fn next_link() -> option<dlist_node<T>> {
5351
self.assert_links();
@@ -109,7 +107,7 @@ fn concat<T>(lists: dlist<dlist<T>>) -> dlist<T> {
109107
result
110108
}
111109

112-
impl private_methods<T> for dlist<T> {
110+
priv impl<T> dlist<T> {
113111
pure fn new_link(-data: T) -> dlist_link<T> {
114112
some(dlist_node(@{data: data, mut linked: true,
115113
mut prev: none, mut next: none}))
@@ -184,7 +182,7 @@ impl private_methods<T> for dlist<T> {
184182
}
185183
}
186184
187-
impl extensions<T> for dlist<T> {
185+
impl<T> dlist<T> {
188186
/// Get the size of the list. O(1).
189187
pure fn len() -> uint { self.size }
190188
/// Returns true if the list is empty. O(1).
@@ -413,7 +411,7 @@ impl extensions<T> for dlist<T> {
413411
}
414412
}
415413

416-
impl extensions<T: copy> for dlist<T> {
414+
impl<T: copy> dlist<T> {
417415
/// Remove data from the head of the list. O(1).
418416
fn pop() -> option<T> { self.pop_n().map (|nobe| nobe.data) }
419417
/// Remove data from the tail of the list. O(1).

src/libcore/dvec.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
//
66
// Note that recursive use is not permitted.
77

8-
import dvec_iter::extensions;
98
import unsafe::reinterpret_cast;
10-
import ptr::{null, extensions};
9+
import ptr::null;
1110

1211
export dvec;
1312
export from_elem;
@@ -75,7 +74,7 @@ fn unwrap<A>(-d: dvec<A>) -> ~[mut A] {
7574
return v;
7675
}
7776

78-
impl private_methods<A> for dvec<A> {
77+
priv impl<A> dvec<A> {
7978
pure fn check_not_borrowed() {
8079
unsafe {
8180
let data: *() = unsafe::reinterpret_cast(self.data);
@@ -107,7 +106,7 @@ impl private_methods<A> for dvec<A> {
107106
// In theory, most everything should work with any A, but in practice
108107
// almost nothing works without the copy bound due to limitations
109108
// around closures.
110-
impl extensions<A> for dvec<A> {
109+
impl<A> dvec<A> {
111110
/// Reserves space for N elements
112111
fn reserve(count: uint) {
113112
vec::reserve(self.data, count)
@@ -188,7 +187,7 @@ impl extensions<A> for dvec<A> {
188187
}
189188
}
190189
191-
impl extensions<A:copy> for dvec<A> {
190+
impl<A: copy> dvec<A> {
192191
/**
193192
* Append all elements of a vector to the end of the list
194193
*
@@ -311,7 +310,7 @@ impl extensions<A:copy> for dvec<A> {
311310
}
312311
}
313312

314-
impl extensions<A:copy> of index<uint,A> for dvec<A> {
313+
impl<A:copy> dvec<A>: index<uint,A> {
315314
pure fn index(&&idx: uint) -> A {
316315
self.get_elt(idx)
317316
}

src/libcore/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pure fn log2(n: f32) -> f32 {
167167
return ln(n) / consts::ln_2;
168168
}
169169

170-
impl num of num::num for f32 {
170+
impl f32: num::num {
171171
pure fn add(&&other: f32) -> f32 { return self + other; }
172172
pure fn sub(&&other: f32) -> f32 { return self - other; }
173173
pure fn mul(&&other: f32) -> f32 { return self * other; }

src/libcore/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ pure fn log2(n: f64) -> f64 {
194194
return ln(n) / consts::ln_2;
195195
}
196196

197-
impl num of num::num for f64 {
197+
impl f64: num::num {
198198
pure fn add(&&other: f64) -> f64 { return self + other; }
199199
pure fn sub(&&other: f64) -> f64 { return self - other; }
200200
pure fn mul(&&other: f64) -> f64 { return self * other; }

src/libcore/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ pure fn sin(x: float) -> float { f64::sin(x as f64) as float }
409409
pure fn cos(x: float) -> float { f64::cos(x as f64) as float }
410410
pure fn tan(x: float) -> float { f64::tan(x as f64) as float }
411411

412-
impl num of num::num for float {
412+
impl float: num::num {
413413
pure fn add(&&other: float) -> float { return self + other; }
414414
pure fn sub(&&other: float) -> float { return self - other; }
415415
pure fn mul(&&other: float) -> float { return self * other; }

src/libcore/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum future<A> = {
3232
};
3333

3434
/// Methods on the `future` type
35-
impl extensions<A:copy send> for future<A> {
35+
impl<A:copy send> future<A> {
3636

3737
fn get() -> A {
3838
//! Get the value of the future

src/libcore/int-template.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,20 @@ pure fn abs(i: T) -> T {
6262
if is_negative(i) { -i } else { i }
6363
}
6464

65-
impl ord of ord for T {
65+
impl T: ord {
6666
pure fn lt(&&other: T) -> bool {
6767
return self < other;
6868
}
6969
}
7070

71-
impl eq of eq for T {
71+
impl T: eq {
7272
pure fn eq(&&other: T) -> bool {
7373
return self == other;
7474
}
7575
}
7676

7777

78-
impl num of num::num for T {
78+
impl T: num::num {
7979
pure fn add(&&other: T) -> T { return self + other; }
8080
pure fn sub(&&other: T) -> T { return self - other; }
8181
pure fn mul(&&other: T) -> T { return self * other; }
@@ -87,7 +87,7 @@ impl num of num::num for T {
8787
pure fn from_int(n: int) -> T { return n as T; }
8888
}
8989

90-
impl times of iter::times for T {
90+
impl T: iter::times {
9191
#[inline(always)]
9292
#[doc = "A convenience form for basic iteration. Given a variable `x` \
9393
of any numeric type, the expression `for x.times { /* anything */ }` \
@@ -107,7 +107,7 @@ impl times of iter::times for T {
107107
}
108108
}
109109

110-
impl timesi of iter::timesi for T {
110+
impl T: iter::timesi {
111111
#[inline(always)]
112112
/// Like `times`, but provides an index
113113
fn timesi(it: fn(uint) -> bool) {

src/libcore/io.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Basic input/output
66

77
import result::result;
88

9-
import dvec::{dvec, extensions};
9+
import dvec::dvec;
1010
import libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t};
1111
import libc::consts::os::posix88::*;
1212
import libc::consts::os::extra::*;
@@ -42,7 +42,7 @@ trait reader {
4242

4343
// Generic utility functions defined on readers
4444

45-
impl reader_util for reader {
45+
impl reader {
4646
fn read_bytes(len: uint) -> ~[u8] {
4747
let mut buf = ~[mut];
4848
vec::reserve(buf, len);
@@ -203,7 +203,7 @@ fn convert_whence(whence: seek_style) -> i32 {
203203
};
204204
}
205205

206-
impl of reader for *libc::FILE {
206+
impl *libc::FILE: reader {
207207
fn read(buf: &[mut u8], len: uint) -> uint {
208208
do vec::as_buf(buf) |buf_p, buf_len| {
209209
assert buf_len <= len;
@@ -227,7 +227,7 @@ impl of reader for *libc::FILE {
227227
// A forwarding impl of reader that also holds on to a resource for the
228228
// duration of its lifetime.
229229
// FIXME there really should be a better way to do this // #2004
230-
impl <T: reader, C> of reader for {base: T, cleanup: C} {
230+
impl<T: reader, C> {base: T, cleanup: C}: reader {
231231
fn read(buf: &[mut u8], len: uint) -> uint { self.base.read(buf, len) }
232232
fn read_byte() -> int { self.base.read_byte() }
233233
fn unread_byte(byte: int) { self.base.unread_byte(byte); }
@@ -273,7 +273,7 @@ fn file_reader(path: ~str) -> result<reader, ~str> {
273273
274274
type byte_buf = {buf: ~[const u8], mut pos: uint, len: uint};
275275
276-
impl of reader for byte_buf {
276+
impl byte_buf: reader {
277277
fn read(buf: &[mut u8], len: uint) -> uint {
278278
let count = uint::min(len, self.len - self.pos);
279279
@@ -343,15 +343,15 @@ trait writer {
343343
fn get_type() -> writer_type;
344344
}
345345

346-
impl <T: writer, C> of writer for {base: T, cleanup: C} {
346+
impl<T: writer, C> {base: T, cleanup: C}: writer {
347347
fn write(bs: &[const u8]) { self.base.write(bs); }
348348
fn seek(off: int, style: seek_style) { self.base.seek(off, style); }
349349
fn tell() -> uint { self.base.tell() }
350350
fn flush() -> int { self.base.flush() }
351351
fn get_type() -> writer_type { file }
352352
}
353353

354-
impl of writer for *libc::FILE {
354+
impl *libc::FILE: writer {
355355
fn write(v: &[const u8]) {
356356
do vec::as_const_buf(v) |vbuf, len| {
357357
let nout = libc::fwrite(vbuf as *c_void, len as size_t,
@@ -384,7 +384,7 @@ fn FILE_writer(f: *libc::FILE, cleanup: bool) -> writer {
384384
}
385385
}
386386

387-
impl of writer for fd_t {
387+
impl fd_t: writer {
388388
fn write(v: &[const u8]) {
389389
let mut count = 0u;
390390
do vec::as_const_buf(v) |vbuf, len| {
@@ -658,7 +658,7 @@ fn println(s: &str) { stdout().write_line(s); }
658658
659659
type mem_buffer = @{buf: dvec<u8>, mut pos: uint};
660660
661-
impl of writer for mem_buffer {
661+
impl mem_buffer: writer {
662662
fn write(v: &[const u8]) {
663663
// Fast path.
664664
let vlen = vec::len(v);

0 commit comments

Comments
 (0)