|
|
|
|
|
by dataflow
530 days ago
|
|
> I agree that your new code does roughly what you'd do in C++ if you wanted this, but you get to the same place as before -- if for example you try commenting out your allocation failure boolean, the code just blows up now. There are lots of APIs like this which make sense in Rust but not in C++ because if you write them in Rust the programmer is going to handle edge cases properly, but in C++ the programmer just ignores the edge cases so why bother. Er... doesn't this blow up in Rust? https://godbolt.org/z/eaaq43voT pub fn main() {
let mut vec = Vec::new();
return vec.push_within_capacity(1).unwrap();
}
|
|
"But I can write correct C++" is trivially true because it's a Turing Complete language, and at the same time entirely useless unless you're playing "Um, actually".