Closed
Description
I'm running into an issue with an interaction between ToStr and pointers that I'm not sure how to handle. I have a struct with a ToStr, and I want to call that method on a @-pointer to the struct. However, to_str.rs provides a generic implementation:
impl<A: ToStr> @A: ToStr { ... }
that returns the to_str prefixed with "@". I do not want this behavior, but I can't figure out how to override it. My naive implementation is:
#[crate_type = "bin"];
pub struct Foo {
v: uint,
}
impl Foo: to_str::ToStr {
pure fn to_str (&self) -> ~str { ~"stacky" }
}
impl @Foo: to_str::ToStr {
pure fn to_str (&self) -> ~str { ~"at-pointer" }
}
fn main () {
let q = @Foo { v: 0 };
io::print (q.to_str () + "\n");
}
But this gives a compile error about multiple implementations. Is there a way around this?
Metadata
Metadata
Assignees
Labels
No labels