say we have a complex struct Foo
struct Foo<'a, 'b, ..., A, B, C, D, ...> {
...
}
with its impls:
impl<'a, 'b, ..., A, B, C, D, ...> Foo<'a, 'b, ..., A, B, C, D, ...> where
A: Clone,
B: Debug,
...
{
fn bar(&'a self) { ... }
...
}
now after some heavy development we may see this impl become insanely big, and make us want to split the methods to separate module, say, sub-module impl_bar
:
mod impl_bar;
now, remember that the generic bounds of Foo
is really complex, and we have to repeat these bounds in our new file impl_bar.rs
How about we create a new syntax, say we can write this in impl_bar.rs
fn bar_helper<'a, 'b, ..., A, B, C, D, ...>(&'a Foo) where as super::Foo { ... }
so we don't have to copy bounds from struct Foo
to write our helper function
in detail we can copy token tree from bounds of Foo
, and check if generic parameters are compatible
with this feature we will encourage user to wirte more sane code