2022-02-17 12:28:07 -08:00
|
|
|
struct Foo {
|
|
|
|
bar: Bar,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar {
|
|
|
|
qux: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn post_field() {
|
|
|
|
let foo = Foo { bar: Bar { qux: 0 } };
|
|
|
|
foo.bar.qux++;
|
|
|
|
//~^ ERROR Rust has no postfix increment operator
|
|
|
|
println!("{}", foo.bar.qux);
|
|
|
|
}
|
|
|
|
|
2022-02-17 14:58:46 -08:00
|
|
|
fn post_field_tmp() {
|
|
|
|
struct S {
|
|
|
|
tmp: i32
|
|
|
|
}
|
|
|
|
let s = S { tmp: 0 };
|
|
|
|
s.tmp++;
|
|
|
|
//~^ ERROR Rust has no postfix increment operator
|
|
|
|
println!("{}", s.tmp);
|
|
|
|
}
|
|
|
|
|
2022-02-17 12:28:07 -08:00
|
|
|
fn pre_field() {
|
|
|
|
let foo = Foo { bar: Bar { qux: 0 } };
|
|
|
|
++foo.bar.qux;
|
|
|
|
//~^ ERROR Rust has no prefix increment operator
|
|
|
|
println!("{}", foo.bar.qux);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
post_field();
|
2022-02-17 14:58:46 -08:00
|
|
|
post_field_tmp();
|
2022-02-17 12:28:07 -08:00
|
|
|
pre_field();
|
|
|
|
}
|