On 12/02/2013 11:12 AM, jeti...@web.de wrote:
Hello,
I lately had a look at Rust and really liked it in many ways. Rust has really
everything I'm missing in Go ;-). There is something about traits I would like
to ask I can't see from the manual. Question is whether you define instance
variables in traits or abstract variables like Ceylon and Kotlin have them.
Abstract traits vars in Kotlin look like this (sample code taken from here:
http://blog.jetbrains.com/kotlin/2011/08/multiple-inheritance-part-2-possible-directions):
trait Trait {
   val property : Int // abstract
   fun foo() {
     print(property)
   }
}
class C() : Trait {
   override val property : Int = 239
}
Can something like this be done for traits in Rust as well?
Then I would like to ask whether you are planning to have some Rust forum for
users. The question I was asking in this mail on rust-dev really doesn't belong
into the dev mailing list. So something like a google Rust-users newsgroup would
be a good thing to have. I know several people that are interested in Rush.
Think it would give Rust a little push if a Rust-user forum would exist.
Regards, Oliver

I would love it. Of the 2 cases of custom traits I have defined do far in Rust, one is only about 3 instance vars (thus ends up empty), the other about 1 vars and 1 method (thus holds only the latter). I find traits weird without vars, and annoying since the compiler does not know that the conforming types _do_ have such vars (thus one is forced to down-cast for no other reason that vars are absent from the trait def, or do i miss a point?). This, in addition to control of actual conformity of types to declared traits.

Denis
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to