Adding struct members in traits would be… weird. Where would those members be 
stored when passing things around by value?

This sounds like something for properties. But as Nikko says it is not a 
planned feature at the moment – there is enough on the table for 1.0 as it is. 
I'm sure they would be a controversial proposal too (although I think they 
would be nice).

~Brendan

On 20/09/2013, at 9:02 PM, Andres Osinski <[email protected]> wrote:

> Hi all, I have a question which I'm sure must have already been discussed and 
> dealt with, but I wanted to understand the design rationale:
> 
> A lot of trait-level functionality would be enhanced if a trait could specify 
> members to be included in the struct which implements the trait. This can be 
> solved in practice by wrapping member access in accessor methods, but I fail 
> to see why that would be preferable.
> 
> The reason I'm asking is because I'm trying to design data structures which 
> contain a couple of arrays, and I wanted to define the trait by not only a 
> set of supported operations but by the existence of both arrays so that a 
> default method could deal with any struct which implements the trait, instead 
> of having to define for every struct an accessor method for each structure 
> and then have to call the accessors in the trait to do anything.
> 
> Thanks
> 
> -- 
> Andrés Osinski
> http://www.andresosinski.com.ar/
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to