On Sat, May 3, 2014 at 6:26 PM, Thomas Hunger <[email protected]> wrote:
> trait PlanReader<R: io::Reader> {
> // read [s] type
> fn read_9p_s(&mut self) -> io::IoResult<~str> {
> let n = self.read_le_u16().unwrap();
> let s = str::from_chars(self.chars().take(n)).unwrap();
> return result::Ok(s);
> }
> }
This declares PlanReader as being parameterized by some type that
implements io::Reader, but that type has nothing to do with Self.
Also, method implementations in trait definitions are only defaults
for types that implement the trait; an impl is still required to
declare that a type implements it.
You probably want:
trait PlanReader {
fn read_9p_s(&mut self) -> io::IoResult<~str>;
}
impl<R: io::Reader> PlanReader for R {
fn read_9p_s(&mut self) -> io::IoResult<~str> { ... }
}
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev