Consider the following code
----------------------------------------------------------------------
pub trait Inner {
fn secret(&self);
}
// This doesn't seem to help.
impl Inner for @Inner {
fn secret(&self) { self.secret(); }
}
pub trait Wrapper {
fn blort(&self);
}
impl<T: Inner> Wrapper for T {
fn blort(&self) { self.secret(); }
}
// This function causes an assertion failure in rustc:
// task <unnamed> failed at 'assertion failed: rp.is_none()',
/home/davidb/rust/rust/src/librustc/middle/typeck/collect.rs:1108
// fn blort<'self, T: Inner>(item: &'self @T) {
// item.secret();
// }
struct Client;
impl Inner for Client {
fn secret(&self) { }
}
fn main() {
let buf = @Client;
buf.secret(); // Works
// error: failed to find an implementation of trait Inner for
// @Client
buf.blort();
}
----------------------------------------------------------------------
This fails to compile:
wrap.rs:32:4: 41:5 error: type `Client` does not implement any method in scope
named `with_data`
I'm modeling this after looking at the code in libstd/io.rs, but I'm
not sure what I'm missing.
I seem to be able to make it work by using 'impl Inner for @Client',
but I'm not sure why that is required.
Also, the commented out function causes an assertion failure in the
compiler (it was a workaround attempt).
Thanks,
David
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev