As far as I can tell, the below code should work, but it errors:
use core::marker::PhantomData;
pub trait Value: Sized {}
pub struct Val<'ctx: 'scope, 'scope, T: Value> {
_phantom: PhantomData<(&'scope &'ctx (), T)>,
}
pub trait AggregateValue<'ctx: 'scope, 'scope>: Value {
type AggregateOfVals: Copy + 'scope;
fn match_val<
'inner_scope,
R: Value,
F: 'scope
+ FnMut(
<Self as AggregateValue<'ctx, 'inner_scope>>::AggregateOfVals,
) -> Val<'ctx, 'inner_scope, R>,
>(
value: Val<'ctx, 'scope, Self>,
f: F,
inner_scope: &'inner_scope (),
) -> Val<'ctx, 'scope, R>
where
'scope: 'inner_scope,
Self: AggregateValue<'ctx, 'inner_scope>;
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0284]: type annotations needed: cannot satisfy `<Self as AggregateValue<'ctx, 'inner_scope>>::AggregateOfVals == _`
--> src/lib.rs:12:5
|
12 | / fn match_val<
13 | | 'inner_scope,
14 | | R: Value,
15 | | F: 'scope
... |
25 | | 'scope: 'inner_scope,
26 | | Self: AggregateValue<'ctx, 'inner_scope>;
| |_________________________________________________^ cannot satisfy `<Self as AggregateValue<'ctx, 'inner_scope>>::AggregateOfVals == _`
error[E0284]: type annotations needed: cannot satisfy `<Self as AggregateValue<'ctx, 'inner_scope>>::AggregateOfVals == <Self as AggregateValue<'ctx, 'inner_scope>>::AggregateOfVals`
--> src/lib.rs:12:8
|
12 | fn match_val<
| ^^^^^^^^^ cannot satisfy `<Self as AggregateValue<'ctx, 'inner_scope>>::AggregateOfVals == <Self as AggregateValue<'ctx, 'inner_scope>>::AggregateOfVals`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0284`.
error: could not compile `playground`
To learn more, run the command again with --verbose.