Skip to content

Commit 88f0a10

Browse files
committed
auto merge of #5277 : bstrie/rust/deimpselfstd, r=brson
2 parents cfba0c7 + 0fed29c commit 88f0a10

14 files changed

+128
-127
lines changed

src/libstd/arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub impl<T:Const + Owned> RWARC<T> {
335335
* Failing will unlock the ARC while unwinding. However, unlike all other
336336
* access modes, this will not poison the ARC.
337337
*/
338-
fn read<U>(blk: fn(x: &T) -> U) -> U {
338+
fn read<U>(&self, blk: fn(x: &T) -> U) -> U {
339339
let state = unsafe { get_shared_immutable_state(&self.x) };
340340
do (&state.lock).read {
341341
check_poison(false, state.failed);
@@ -360,7 +360,7 @@ pub impl<T:Const + Owned> RWARC<T> {
360360
* }
361361
* ~~~
362362
*/
363-
fn write_downgrade<U>(blk: fn(v: RWWriteMode<T>) -> U) -> U {
363+
fn write_downgrade<U>(&self, blk: fn(v: RWWriteMode<T>) -> U) -> U {
364364
unsafe {
365365
let state = get_shared_mutable_state(&self.x);
366366
do (*borrow_rwlock(state)).write_downgrade |write_mode| {
@@ -373,7 +373,7 @@ pub impl<T:Const + Owned> RWARC<T> {
373373
}
374374
375375
/// To be called inside of the write_downgrade block.
376-
fn downgrade(token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
376+
fn downgrade(&self, token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
377377
// The rwlock should assert that the token belongs to us for us.
378378
let state = unsafe { get_shared_immutable_state(&self.x) };
379379
let RWWriteMode((data, t, _poison)) = token;

src/libstd/base64.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use core::str;
1313
use core::vec;
1414

1515
pub trait ToBase64 {
16-
pure fn to_base64() -> ~str;
16+
pure fn to_base64(&self) -> ~str;
1717
}
1818

1919
impl ToBase64 for &self/[u8] {
20-
pure fn to_base64() -> ~str {
20+
pure fn to_base64(&self) -> ~str {
2121
let chars = str::chars(
2222
~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
2323
);
@@ -70,17 +70,17 @@ impl ToBase64 for &self/[u8] {
7070
}
7171
7272
impl ToBase64 for &self/str {
73-
pure fn to_base64() -> ~str {
74-
str::to_bytes(self).to_base64()
73+
pure fn to_base64(&self) -> ~str {
74+
str::to_bytes(*self).to_base64()
7575
}
7676
}
7777
7878
pub trait FromBase64 {
79-
pure fn from_base64() -> ~[u8];
79+
pure fn from_base64(&self) -> ~[u8];
8080
}
8181
8282
impl FromBase64 for ~[u8] {
83-
pure fn from_base64() -> ~[u8] {
83+
pure fn from_base64(&self) -> ~[u8] {
8484
if self.len() % 4u != 0u { fail!(~"invalid base64 length"); }
8585
8686
let len = self.len();
@@ -142,8 +142,8 @@ impl FromBase64 for ~[u8] {
142142
}
143143
144144
impl FromBase64 for ~str {
145-
pure fn from_base64() -> ~[u8] {
146-
str::to_bytes(self).from_base64()
145+
pure fn from_base64(&self) -> ~[u8] {
146+
str::to_bytes(*self).from_base64()
147147
}
148148
}
149149

src/libstd/comm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ pub struct DuplexStream<T, U> {
2929
#[cfg(stage1)]
3030
#[cfg(stage2)]
3131
pub impl<T:Owned,U:Owned> DuplexStream<T, U> {
32-
fn send(x: T) {
32+
fn send(&self, x: T) {
3333
self.chan.send(x)
3434
}
35-
fn try_send(x: T) -> bool {
35+
fn try_send(&self, x: T) -> bool {
3636
self.chan.try_send(x)
3737
}
38-
fn recv() -> U {
38+
fn recv(&self, ) -> U {
3939
self.port.recv()
4040
}
41-
fn try_recv() -> Option<U> {
41+
fn try_recv(&self) -> Option<U> {
4242
self.port.try_recv()
4343
}
44-
pure fn peek() -> bool {
44+
pure fn peek(&self) -> bool {
4545
self.port.peek()
4646
}
4747
}

src/libstd/ebml.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub mod reader {
217217
}
218218

219219
priv impl Decoder {
220-
fn _check_label(lbl: &str) {
220+
fn _check_label(&self, lbl: &str) {
221221
if self.pos < self.parent.end {
222222
let TaggedDoc { tag: r_tag, doc: r_doc } =
223223
doc_at(self.parent.data, self.pos);
@@ -233,7 +233,7 @@ pub mod reader {
233233
}
234234
}
235235

236-
fn next_doc(exp_tag: EbmlEncoderTag) -> Doc {
236+
fn next_doc(&self, exp_tag: EbmlEncoderTag) -> Doc {
237237
debug!(". next_doc(exp_tag=%?)", exp_tag);
238238
if self.pos >= self.parent.end {
239239
fail!(~"no more documents in current node!");
@@ -255,7 +255,7 @@ pub mod reader {
255255
r_doc
256256
}
257257
258-
fn push_doc<T>(d: Doc, f: fn() -> T) -> T {
258+
fn push_doc<T>(&self, d: Doc, f: fn() -> T) -> T {
259259
let old_parent = self.parent;
260260
let old_pos = self.pos;
261261
self.parent = d;
@@ -266,7 +266,7 @@ pub mod reader {
266266
r
267267
}
268268
269-
fn _next_uint(exp_tag: EbmlEncoderTag) -> uint {
269+
fn _next_uint(&self, exp_tag: EbmlEncoderTag) -> uint {
270270
let r = doc_as_u32(self.next_doc(exp_tag));
271271
debug!("_next_uint exp_tag=%? result=%?", exp_tag, r);
272272
r as uint
@@ -446,7 +446,7 @@ pub mod writer {
446446
447447
// FIXME (#2741): Provide a function to write the standard ebml header.
448448
pub impl Encoder {
449-
fn start_tag(tag_id: uint) {
449+
fn start_tag(&self, tag_id: uint) {
450450
debug!("Start tag %u", tag_id);
451451
452452
// Write the enum ID:
@@ -458,7 +458,7 @@ pub mod writer {
458458
self.writer.write(zeroes);
459459
}
460460
461-
fn end_tag() {
461+
fn end_tag(&self) {
462462
let last_size_pos = self.size_positions.pop();
463463
let cur_pos = self.writer.tell();
464464
self.writer.seek(last_size_pos as int, io::SeekSet);
@@ -469,72 +469,72 @@ pub mod writer {
469469
debug!("End tag (size = %u)", size);
470470
}
471471
472-
fn wr_tag(tag_id: uint, blk: fn()) {
472+
fn wr_tag(&self, tag_id: uint, blk: fn()) {
473473
self.start_tag(tag_id);
474474
blk();
475475
self.end_tag();
476476
}
477477
478-
fn wr_tagged_bytes(tag_id: uint, b: &[u8]) {
478+
fn wr_tagged_bytes(&self, tag_id: uint, b: &[u8]) {
479479
write_vuint(self.writer, tag_id);
480480
write_vuint(self.writer, vec::len(b));
481481
self.writer.write(b);
482482
}
483483
484-
fn wr_tagged_u64(tag_id: uint, v: u64) {
484+
fn wr_tagged_u64(&self, tag_id: uint, v: u64) {
485485
do io::u64_to_be_bytes(v, 8u) |v| {
486486
self.wr_tagged_bytes(tag_id, v);
487487
}
488488
}
489489
490-
fn wr_tagged_u32(tag_id: uint, v: u32) {
490+
fn wr_tagged_u32(&self, tag_id: uint, v: u32) {
491491
do io::u64_to_be_bytes(v as u64, 4u) |v| {
492492
self.wr_tagged_bytes(tag_id, v);
493493
}
494494
}
495495
496-
fn wr_tagged_u16(tag_id: uint, v: u16) {
496+
fn wr_tagged_u16(&self, tag_id: uint, v: u16) {
497497
do io::u64_to_be_bytes(v as u64, 2u) |v| {
498498
self.wr_tagged_bytes(tag_id, v);
499499
}
500500
}
501501
502-
fn wr_tagged_u8(tag_id: uint, v: u8) {
502+
fn wr_tagged_u8(&self, tag_id: uint, v: u8) {
503503
self.wr_tagged_bytes(tag_id, &[v]);
504504
}
505505
506-
fn wr_tagged_i64(tag_id: uint, v: i64) {
506+
fn wr_tagged_i64(&self, tag_id: uint, v: i64) {
507507
do io::u64_to_be_bytes(v as u64, 8u) |v| {
508508
self.wr_tagged_bytes(tag_id, v);
509509
}
510510
}
511511
512-
fn wr_tagged_i32(tag_id: uint, v: i32) {
512+
fn wr_tagged_i32(&self, tag_id: uint, v: i32) {
513513
do io::u64_to_be_bytes(v as u64, 4u) |v| {
514514
self.wr_tagged_bytes(tag_id, v);
515515
}
516516
}
517517
518-
fn wr_tagged_i16(tag_id: uint, v: i16) {
518+
fn wr_tagged_i16(&self, tag_id: uint, v: i16) {
519519
do io::u64_to_be_bytes(v as u64, 2u) |v| {
520520
self.wr_tagged_bytes(tag_id, v);
521521
}
522522
}
523523
524-
fn wr_tagged_i8(tag_id: uint, v: i8) {
524+
fn wr_tagged_i8(&self, tag_id: uint, v: i8) {
525525
self.wr_tagged_bytes(tag_id, &[v as u8]);
526526
}
527527
528-
fn wr_tagged_str(tag_id: uint, v: &str) {
528+
fn wr_tagged_str(&self, tag_id: uint, v: &str) {
529529
str::byte_slice(v, |b| self.wr_tagged_bytes(tag_id, b));
530530
}
531531
532-
fn wr_bytes(b: &[u8]) {
532+
fn wr_bytes(&self, b: &[u8]) {
533533
debug!("Write %u bytes", vec::len(b));
534534
self.writer.write(b);
535535
}
536536
537-
fn wr_str(s: &str) {
537+
fn wr_str(&self, s: &str) {
538538
debug!("Write str: %?", s);
539539
self.writer.write(str::to_bytes(s));
540540
}
@@ -549,12 +549,12 @@ pub mod writer {
549549
550550
priv impl Encoder {
551551
// used internally to emit things like the vector length and so on
552-
fn _emit_tagged_uint(t: EbmlEncoderTag, v: uint) {
552+
fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) {
553553
assert v <= 0xFFFF_FFFF_u;
554554
self.wr_tagged_u32(t as uint, v as u32);
555555
}
556556
557-
fn _emit_label(label: &str) {
557+
fn _emit_label(&self, label: &str) {
558558
// There are various strings that we have access to, such as
559559
// the name of a record field, which do not actually appear in
560560
// the encoded EBML (normally). This is just for

src/libstd/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ priv enum FutureState<A> {
4747

4848
/// Methods on the `future` type
4949
pub impl<A:Copy> Future<A> {
50-
fn get() -> A {
50+
fn get(&self) -> A {
5151
//! Get the value of the future
5252
*(self.get_ref())
5353
}

src/libstd/io_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub impl BufReader {
2424
}
2525
}
2626

27-
priv fn as_bytes_reader<A>(f: &fn(&BytesReader) -> A) -> A {
27+
priv fn as_bytes_reader<A>(&self, f: &fn(&BytesReader) -> A) -> A {
2828
// Recreating the BytesReader state every call since
2929
// I can't get the borrowing to work correctly
3030
let bytes_reader = BytesReader {

0 commit comments

Comments
 (0)