I'm sorry for being kind of off-topic here, but whatever you decide on this
matter, I'd still like to be able to emulate multiple-inheritance using the
following idiom (which requires being able to say that a trait method is
private or, preferably, why don't we make trait methods private by default):
trait Inflate {
priv fn get_radius<'s>(&'s mut self) -> &'s mut int;
fn inflate_by(&mut self, amount: int) {
*self.get_radius() += amount;
}
// ... rest of the implementation ...
}
trait Flatten {
priv fn getRadius<'s>(&'s mut self) -> &'s mut int;
fn release_all_air(&mut self) {
*self.getRadius() = 0;
}
// ... rest of the implementation ...
}
struct Balloon {
radius: int
}
impl Inflate for Balloon {
priv fn get_radius<'s>(&'s mut self) -> &'s mut int {
&mut self.radius
}
}
impl Flatten for Balloon {
priv fn getRadius<'s>(&'s mut self) -> &'s mut int {
&mut self.radius
}
}
fn main() {
let mut b = Balloon { radius: 123 };
b.inflate_by(10);
b.release_all_air();
// b.get_radius(); // ERROR: get_radius is private
// b.getRadius(); // ERROR: getRadius is private
}
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev