Hacker News new | ask | show | jobs
by benhoyt 1925 days ago
Out of interest, how do you compare/store in a map? Do you convert to a string, or a [4]byte array (for IPv4), or some other comparable/hashable type?
1 comments

Either strings or (in the common case where I know I'm dealing with v4) uint32's. In fact, I probably do v6 stuff with uint32s too (I'm never working with an arbitrarily large v6 prefix).

I think this post is right about net.IP, though I also think the solution they've reached is Lovecraftian. But I write Rust, too, and I'd take net.IP over Sockaddr any day of the week.

I assume you mean std::net::SocketAddr? Out of curiosity, what's wrong with it?
I'd assume the lackluster selection of operations and how deeply nested some of the information is within the type. Definitely not the most ergonomic thing.

My personal favorite is probably the python ones. Only annoyance is difficulty of creating modified objects from existing ones.