4 ms·
My only complaint is the mix between snake_case and PascalCase. I tried removing it(in favor of snake_case, but you could probably get a similar result if going
by Sacho 10y ago
My only complaint is the mix between snake_case and PascalCase. I tried removing it(in favor of snake_case, but you could probably get a similar result if going full PascalCase), and it looks much better(no guarantee it has the same semantics, I've never worked with rust):
fn handle_message(&mut self, find_node_query: messages::find_node_query) {
let origin = node::udp_node::deserialize(find_node_query.get_origin());
let target = address::from_str(find_node_query.get_target());
{
// Borrow self.routing_table first time
let nodes: vec<&box<node::node>> = self.routing_table.nearest_to(&target);
let response = message::response(
self.transaction_ids.generate(),
response::find_node(&self.self_node, nodes)
);
origin.send(response.serialize());
} // Done borrowing self.routing_table here
// Borrow self.routing_table again
self.routing_table.insert(origin);
}
- pcwalton 10y agoRust used to work that way, but it was changed primarily to visually distinguish between enumerated variant names and variable bindings in patterns. e.g. match foo { none => ... } and match foo { non => ... } having completely different interpretations was confusing.
- kibwen 10y agoIt sure does look more like C that way (if that's something you're into), but that also makes it harder to scan for types at a glance.