3 ms·
I am not saying you are wrong because I do not know Rust but it appears you only consider variables in your case and not cont parameters for methods and cont m
by simion314 7y ago
I am not saying you are wrong because I do not know Rust but it appears you only consider variables in your case and not cont parameters for methods and cont methods. The const keyword is used for different things in c++ not like let in other languages that is used only for variable declarations. I apologize if I misunderstood your point.
- nayuki 7y agoGood point - by dwelling on variables, I failed respond to the article on the precise topic. Now I'll illustrate const methods and parameters as per your suggestion. Rust: fn reads_myself(&self) { ... } fn writes_myself(&mut self) { ... } fn reads_arg(w: &Widget) { ... } fn writes_arg(w: &mut Widget) { ... } C++: void readsMyself() const { ... } void writesMyself() { ... } void readsArg(const Widget &w) { ... } void writesArg(Widget &w) { ... }
- Inityx 7y agoRust treats parameters identically to local variables, since they are just local variables. All rules that apply to variables also apply to all function arguments (including `this`/`self`).