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 HashMap>, nodes: &Vec>) -> bool { for n in nodes.iter() { if !self.collect_node_names(map, &n.subnodes) { return false; } match n.name { Some(ref name) => { if map.co

[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 = self