capnproto-rust
capnproto-rust copied to clipboard
Small codegen alteration question/request regarding generic types with nested nodes
Currently, nested capnp struct definitions translate into rust codegen builders/readers /etc that contain ALL possible generic types, even if they do not use them. For example:
struct RootStruct(T) {
tVal @0 :T;
struct SubStruct(R) {
rVal @0 :R;
}
}
The SubStruct mod's structs contain both T and R generic types, even though they only use R.
root_struct::sub_struct::Builder<T,R>
Here are some examples of some awkward usage this can potentially cause:
let builder = TypedBuilder::<sub_struct::Owned<XXXX_unused_XXXXX, some_struct::Owned>>::new_default();
fn write_to_builder(builder: sub_struct::Builder<XXXX_unused_XXXXX, some_struct::Owned>);
Given the changes in this recent commit, is there any architectural reason it would not be possible to expand the concept of only including used generic types in struct/interface/group definitions instead of only unions? From some of my own (albeit limited) tests, it seems like it would be ok.