1,156 karma · joined Jan 11, 2022 (4y ago) · 205 submissions
comment 3y ago · link · parent
That doesn't seem strange to me. At even lower temperatures, water pipes will burst, so you have to heat it at least a little in winter. Waste heat from humans might be enough to avoid freezing temperatures, but then humans also produce a lot of humidity, causing mold.
comment 3y ago · link · parent
Fair point, but it really only matters if the overflow is handled gracefully. If it's handled as an unrecoverable error condition, it often 1. doesn't happen during normal operation and 2. can be invoked by a determined attacker, regardless of the exact size. Sure, the exact characteristics might be different, but in the end it doesn't make much of a difference.
Petgraph has a great API, and in general using newtypes over integers for collection indices is a great way to avoid another logic bug: mixing up indices for different collections.
comment 3y ago · link · parent
- Confusing different integer types is much harder not only because the type checker will complain, but also because you don't really come across anything other than usize/isize unless it's a field in a protocol or something.
- Strings in rust are not zero-terminated, so that specific example might not even happen at all.
- Integers, pointers and references are not implicitly cast to booleans, so you can't accidentally mix up comparing a pointer to NULL (which is only ever required for FFI calls) and comparing an integer to 0.
- You have proper types to indicate that a function encountered an error, so all the issues stemming from checking the integer return code the wrong way (e.g. interpreting an error value as a return value) don't exist.
- You simply don't have to invoke potentially dangerous functions like `memcpy` because there are abstractions that take care of this safely and more intuitively.
That's not to say that idiomatic Rust code wouldn't come with its own problems, but they tend to be much more concentrated to fundamental logic bugs rather than silly avoidable things like overflows or misinterpreting values.
comment 3y ago · link · parent
comment 4y ago · link · parent
New language features may require a new edition, though the vast majority of them don't - here's the list of all the changes in Edition 2021 (a new one is released every 3 years): https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html
comment 4y ago · link · parent
That sounds like trait objects/dynamic dispatch/`dyn`, which comes with runtime costs.
> or have to pattern match later and have a way to tell them apart.
That "way to tell them apart" is a tag, which would make it a tagged union/enum, not an untagged union. Those already exist, though not in an anonymous flavour.
comment 4y ago · link · parent
comment 4y ago · link · parent
143.
Generic associated types to be stable in Rust 1.65(blog.rust-lang.org ↗)
39 points · by proto_lambda · 4y ago · discuss
comment 4y ago · link · parent
The author does know this, it's a reference to a couple paragraphs above:
> [...] and the HTTP protocol version, which is a fixed string which is always set to HTTP/1.1 and nothing else.
> (cool bear) But what ab-
> IT'S SET TO HTTP/1.1 AND NOTHING ELSE.
146.
Compiler optimizations are hard because they forget(faultlore.com ↗)
44 points · by proto_lambda · 4y ago · 4 comments
comment 4y ago · link · parent