blob: ad918ecddebb3acbeb8a7e0e5e75523c419a0bca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// run-pass
// regression test for issue #41498.
struct S;
impl S {
fn mutate(&mut self) {}
}
fn call_and_ref<T, F: FnOnce() -> T>(x: &mut Option<T>, f: F) -> &mut T {
*x = Some(f());
x.as_mut().unwrap()
}
fn main() {
let mut n = None;
call_and_ref(&mut n, || [S])[0].mutate();
}
|