@@ -455,10 +455,15 @@ impl *libc::FILE: Reader {
455
455
}
456
456
}
457
457
458
+ struct Wrapper < T , C > {
459
+ base : T ,
460
+ cleanup : C ,
461
+ }
462
+
458
463
// A forwarding impl of reader that also holds on to a resource for the
459
464
// duration of its lifetime.
460
465
// FIXME there really should be a better way to do this // #2004
461
- impl < T : Reader , C > { base : T , cleanup : C } : Reader {
466
+ impl < R : Reader , C > Wrapper < R , C > : Reader {
462
467
fn read ( & self , bytes : & [ mut u8] , len : uint ) -> uint {
463
468
self . base . read ( bytes, len)
464
469
}
@@ -487,7 +492,7 @@ pub fn FILERes(f: *libc::FILE) -> FILERes {
487
492
488
493
pub fn FILE_reader ( f : * libc:: FILE , cleanup : bool ) -> Reader {
489
494
if cleanup {
490
- { base: f, cleanup: FILERes ( f) } as Reader
495
+ Wrapper { base : f, cleanup : FILERes ( f) } as Reader
491
496
} else {
492
497
f as Reader
493
498
}
@@ -587,7 +592,7 @@ pub trait Writer {
587
592
fn get_type(&self) -> WriterType;
588
593
}
589
594
590
- impl<T : Writer, C> {base: T, cleanup: C} : Writer {
595
+ impl<W : Writer, C> Wrapper<W, C> : Writer {
591
596
fn write(&self, bs: &[const u8]) { self.base.write(bs); }
592
597
fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); }
593
598
fn tell(&self) -> uint { self.base.tell() }
@@ -639,7 +644,7 @@ impl *libc::FILE: Writer {
639
644
640
645
pub fn FILE_writer ( f : * libc:: FILE , cleanup : bool ) -> Writer {
641
646
if cleanup {
642
- { base: f, cleanup: FILERes ( f) } as Writer
647
+ Wrapper { base : f, cleanup : FILERes ( f) } as Writer
643
648
} else {
644
649
f as Writer
645
650
}
@@ -696,7 +701,7 @@ pub fn FdRes(fd: fd_t) -> FdRes {
696
701
697
702
pub fn fd_writer ( fd : fd_t , cleanup : bool ) -> Writer {
698
703
if cleanup {
699
- { base: fd, cleanup: FdRes ( fd) } as Writer
704
+ Wrapper { base : fd, cleanup : FdRes ( fd) } as Writer
700
705
} else {
701
706
fd as Writer
702
707
}
0 commit comments