A question I stumbled upon today, and couldn't find the answer in the reference.
Consider the following program:
structCounter{v:i32}implCounter{fnnext(&mutself) -> i32{self.v += 1;self.v}}fnshow(first:i32,second:i32){println!("{} {}", first, second);}fnmain(){letmut x = Counter{v:0};show(x.next(), x.next());}In my experience it always prints 1 2 but I want to know whether this is guaranteed, or if it is (like, e.g., in C++) explicitly undefined.
The most obvious place to put the answer is https://doc.rust-lang.org/reference/expressions/call-expr.html (or just https://doc.rust-lang.org/reference/expressions.html)
Same question for order of evaluation of tuple elements.
A question I stumbled upon today, and couldn't find the answer in the reference.
Consider the following program:
In my experience it always prints
1 2but I want to know whether this is guaranteed, or if it is (like, e.g., in C++) explicitly undefined.The most obvious place to put the answer is https://doc.rust-lang.org/reference/expressions/call-expr.html (or just https://doc.rust-lang.org/reference/expressions.html)
Same question for order of evaluation of tuple elements.