]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-103095.rs
Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum
[rust.git] / tests / ui / borrowck / issue-103095.rs
1 // check-pass
2
3 trait FnOnceForGenericRef<T>: FnOnce(&T) -> Self::FnOutput {
4     type FnOutput;
5 }
6
7 impl<T, R, F: FnOnce(&T) -> R> FnOnceForGenericRef<T> for F {
8     type FnOutput = R;
9 }
10
11 struct Data<T, D: FnOnceForGenericRef<T>> {
12     value: Option<T>,
13     output: Option<D::FnOutput>,
14 }
15
16 impl<T, D: FnOnceForGenericRef<T>> Data<T, D> {
17     fn new(value: T, f: D) -> Self {
18         let output = f(&value);
19         Self {
20             value: Some(value),
21             output: Some(output),
22         }
23     }
24 }
25
26 fn test() {
27     Data::new(String::new(), |_| {});
28 }
29
30 fn main() {}