3 ms·
> how to spend a lot of effort to solve a problem you would never have if you didn't use rust No, you don't have that problem even in Rust. Rust has C-like poi
by pornel 8y ago
> how to spend a lot of effort to solve a problem you would never have if you didn't use rust
No, you don't have that problem even in Rust. Rust has C-like pointers, so if you're OK with them, you can just use them as if you were writing a C program.
The effort here was not forced by Rust, but was author's choice to get a guarantee the code is safe. And I'd say it's relatively low effort given it's reusable, and it'll stay safe even after code changes. In C you'd instead do meticulous analysis, debugging and add a comment "// careful, don't break this!"
- rom1v 8y ago> Rust has C-like pointers, so if you're OK with them, you can just use them as if you were writing a C program. This would not be practicable. Raw pointers in Rust are (probably on purpose) far less convenient to use (no operator + or -, not possible to index an "array" with operator []…). Moreover, you would lose all benefits provided by slices (iterators, etc.). And locally converting raw pointers to references just to call these methods could lead to undefined behavior (aliasing of mutable references is forbidden even in unsafe code, see https://stackoverflow.com/questions/54633474/is-aliasing-of-mutable-references-correct-in-unsafe-code https://stackoverflow.com/questions/54633474/is-aliasing-of-...). IMO, using C-like pointers for a whole Rust application would make no sense (it would be worse than just writing a C application).