2024-08-17 07:19:34 -05:00
|
|
|
//@ check-pass
|
|
|
|
|
2018-11-19 04:19:14 -06:00
|
|
|
struct S {
|
|
|
|
state: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl S {
|
|
|
|
const fn foo(&mut self, x: u32) {
|
|
|
|
self.state = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const FOO: S = {
|
|
|
|
let mut s = S { state: 42 };
|
2024-08-17 07:19:34 -05:00
|
|
|
s.foo(3);
|
2018-11-19 04:19:14 -06:00
|
|
|
s
|
|
|
|
};
|
|
|
|
|
2018-12-30 12:20:53 -06:00
|
|
|
type Array = [u32; {
|
|
|
|
let mut x = 2;
|
2024-08-17 07:19:34 -05:00
|
|
|
let y = &mut x;
|
2018-12-30 12:20:53 -06:00
|
|
|
*y = 42;
|
|
|
|
*y
|
|
|
|
}];
|
2018-12-28 13:05:22 -06:00
|
|
|
|
2018-11-19 04:19:14 -06:00
|
|
|
fn main() {
|
|
|
|
assert_eq!(FOO.state, 3);
|
|
|
|
}
|