Closed
Description
A question I stumbled upon today, and couldn't find the answer in the reference.
Consider the following program:
struct Counter {
v : i32
}
impl Counter {
fn next(&mut self) -> i32 {
self.v += 1;
self.v
}
}
fn show(first: i32, second: i32) {
println!("{} {}", first, second);
}
fn main(){
let mut 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.