You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Including both schema files in lib.rs is not possible due to name the obvious name clash.
Therefore one would like to include it directly in the corresponding mod.rs to avoid the name clash. But currently the generated code assumes that its code will be a module at root level and refers to itself with ::schema_capnp in the example above.
This could be easily modified so that it assumes it's included in the same directory as the schema file is so the resulting handle would be ::foo::schema_capnp. But that would make it impossible to include it in a different file other than foo/mod.rs (in the example above), which would break the existing behavior.
I don't have a good idea to solve this.
Personally I feel like forcing the user to include the module in the same directory as the schema file would be better than the current behavior. As it's more natural and name clashes would be impossible.
The text was updated successfully, but these errors were encountered:
mashedcode
changed the title
Include generated code inside of a module which contains the corresponding schema
Resolve name clashes: Include generated code inside of a module which contains the corresponding schema
Aug 30, 2018
mashedcode
changed the title
Resolve name clashes: Include generated code inside of a module which contains the corresponding schema
Name clashes: Include generated code inside of a module which contains the corresponding schema
Aug 30, 2018
Currently the user is expected to include all generated code at project root.
He then may use that code inside of a module:
This may be inconvenient in some cases and not possible to do with the following structure:
Including both schema files in lib.rs is not possible due to name the obvious name clash.
Therefore one would like to include it directly in the corresponding
mod.rs
to avoid the name clash.But currently the generated code assumes that its code will be a module at root level and refers to itself with
::schema_capnp
in the example above.This could be easily modified so that it assumes it's included in the same directory as the schema file is so the resulting handle would be
::foo::schema_capnp
.But that would make it impossible to include it in a different file other than
foo/mod.rs
(in the example above), which would break the existing behavior.I don't have a good idea to solve this.
Personally I feel like forcing the user to include the module in the same directory as the schema file would be better than the current behavior. As it's more natural and name clashes would be impossible.
The text was updated successfully, but these errors were encountered: