-
Notifications
You must be signed in to change notification settings - Fork 542
Closed
Labels
New ContentMissing features or aspects of language not currently documented.Missing features or aspects of language not currently documented.
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.
Metadata
Metadata
Assignees
Labels
New ContentMissing features or aspects of language not currently documented.Missing features or aspects of language not currently documented.