

You are right with this. But still, in Rust, a vector of u8 is different from a sequence of unicode characters. This would not work in Python3 either, while it’d work in Python2.
You are right with this. But still, in Rust, a vector of u8 is different from a sequence of unicode characters. This would not work in Python3 either, while it’d work in Python2.
Thanks, I fixed it!
What I find interesting is that move semantics silently add something to C++ that did not exist before: invalid objects.
Before, if you created an object, you could design it so that it kept all invariants until it was destroyed. I’d even argue that it is the true core of OOP that you get data structures with guaranteed invariants - a vector or hash map or binary heap never ceases to guarantee its invariants.
But now, you can construct complex objects and then move their data away with std::move() .
What happens with the invariants of these objects?
let mut bytes = vec![0u8; len as usize];
buf.read_exact(&mut bytes)?;
// Sanitize control characters
let sanitized_bytes: Vec<u8> = bytes.into_iter()
.filter(|&b| b >= 32 || b == 9 || b == 10 || b == 13) // Allow space, tab, newline, carriage return
.collect();
This implicitly, and wrongly, swaps the interpretation of the input from UTF8 text to pure ASCII.
Did you ever note that when intelligent engineers talk about designs (or quite generally when intelligent people talk about consequential decisions they took), they talk about their goals, about the alternatives they had, about what they knew about the properties of these alternatives and how these evaluated with their goals, about which alternatives they chose in the end and how they addressed the inevitable difficulties they encountered?
For me, this is quite a very telling sign of intelligence in individuals. And truly good engineering organizations do collect and treasure that knowledge - it is path-dependent and you cannot quickly and fully reproduce it when it is lost. And more importantly, some fundamental reasons for your decisions and designs might change, and you might have to revise them. Good decisions also have a quality of stability which is that the route taken does not change dramatically when an external factor changes a little.
So and now compare that to when you let automatically plan a route through a dense, complex suburban train network, by using a routing app. The route you get will likely be the fastest one, with the implicit assumption that this is what you of course want - but any small hiccup or delay in the transport network can well make it the slowest option.
Here are many more pictures in high resolution:
https://www.derbund.ch/zerstoerung-in-blatten-bilder-zeigen-geroelllawine-490800412498
One can see that the rocks are blocking a river, causing up to 30 meters of flooding. Eventually, it will break through.
So what do you do with a file object?