|
|
|
|
|
by woodruffw
1203 days ago
|
|
> Non mutable references don't exist in C. Sure they do: C has a well-defined notion of const-correctness. If you mutate through a `const`, you're invoking undefined behavior. Both C and C++ allow you to strip `const` from a const-qualified value or reference, but only under the condition that you don't actually modify that value. Edit: which, in case it isn't clear, means that Rust's UB is exactly the same as C's in this case. |
|
[1] https://en.cppreference.com/w/cpp/language/const_cast