Re: [rust-dev] self/mut self in traits considered harmful(?)

2014-06-15 Thread Benjamin Striegel
The manner in which the expression accomplishes this task is an implementation detail. You're welcome to draft a proposal if you think that you have an idea to make this possible. Though all of the solutions that I can envision require abandoning the idea of operators-as-traits and introducing a

[rust-dev] Flatten a tree into HashMap, how do I pass a mut around?

2014-06-15 Thread Vladimir Pouzanov
I have a tree of Nodes where each node might have a name. I'm trying to convert the tree into a HashMap of named nodes, but my code is getting extremely complex due to the fact that I cannot pass mut HashMap around. let mut named_nodes = HashMap::new(); let nodes = vec!( ... ); named_nodes =

Re: [rust-dev] self/mut self in traits considered harmful(?)

2014-06-15 Thread Tommi
On 2014-06-15, at 9:56, Benjamin Striegel ben.strie...@gmail.com wrote: You're welcome to draft a proposal if you think that you have an idea to make this possible. The idea of the `stable` keyword was designed specifically as a bandage on the current trait-system to allow a trait to say

Re: [rust-dev] self/mut self in traits considered harmful(?)

2014-06-15 Thread Tommi
I realized that, in my proposal, there's a potentially pretty confusing asymmetry of what `stable` means. In the trait definition: pub trait MulRHS, Result { fn mul(stable self, rhs: RHS) - Result; } ...the keyword `stable` means that however the type which implements this trait decides to

Re: [rust-dev] Flatten a tree into HashMap, how do I pass a mut around?

2014-06-15 Thread Vladimir Pouzanov
After a few hints on IRC I managed to simplify it to: fn collect_node_names(self, map: mut HashMapString, Gcnode::Node, nodes: VecGcnode::Node) - bool { for n in nodes.iter() { if !self.collect_node_names(map, n.subnodes) { return false; } match n.name { Some(ref

Re: [rust-dev] self/mut self in traits considered harmful(?)

2014-06-15 Thread Isaac Dupree
On 6/12/14 11:15 AM, Tommi wrote: But I think it will be easy to make the error of writing the explicit .clone() in places where it's not needed. For example: [...] Would a compiler warning for unnecessary clones be feasible? useful? Would it have false positives -- situations where a clone