2021-06-27 02:22:46 -04:00
|
|
|
// edition:2021
|
2020-11-25 15:15:55 -05:00
|
|
|
// run-pass
|
|
|
|
|
2022-08-18 10:13:37 +08:00
|
|
|
// Tests that if a closure uses individual fields of the same object
|
2020-11-25 15:15:55 -05:00
|
|
|
// then that case is handled properly.
|
|
|
|
|
|
|
|
#![allow(unused)]
|
|
|
|
|
|
|
|
struct Struct {
|
|
|
|
x: i32,
|
|
|
|
y: i32,
|
|
|
|
s: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut s = Struct { x: 10, y: 10, s: String::new() };
|
|
|
|
|
2023-06-12 16:55:36 +08:00
|
|
|
let mut c = || {
|
2020-11-25 15:15:55 -05:00
|
|
|
s.x += 10;
|
|
|
|
s.y += 42;
|
|
|
|
s.s = String::from("new");
|
|
|
|
};
|
|
|
|
}
|