#How do I just copy all type parameters for verbatim use in an enclosing type?
8 messages · Page 1 of 1 (latest)
You can't. A type's generic list can't be dependent on another type's list; you need to specify them explicitly
I can't quite figure out which direction the "dependant" goes in your answer. Do you mean that the ? in Foo<?> must be explicit? Like Foo<ConcreteType>?
No. You can't make MyType's generic list inherit Foo's generic list, or the other way around: they have to be declared separately
You have to manually do this: ```rust
struct MyType<'bar, B: Baz, W: Wut = ()> {
foo: Foo<'bar, B, W>,
}
ooh. ok! that makes sense. it would make no sense for the W: Wut = () to appear inside the struct. I guess it's analogous to a function's parameters (in the declaration) vs arguments (in the body).
depending on what you're doing, it might be possible to work with a
struct MyType<F> {
foo: F,
}
and then you only need to mention the Foo type and its parameters where they are relevant (such as in impl blocks), rather than in every single use of MyType
That too ^