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
It is not clear how to specify the substitute syn::Paths required as argument.
A few things remain puzzling:
what is the relative base module needed to get a substitution match?
does it have to be absolute paths?
do bare types (so i.e. just an Ident) themselves suffice for matching?
let path = &ty.ty.path;// Don't generate a type if it was substituted - the target type might// not be in the type registry + our resolution already performs the substitution.ifself.settings.substitutes.contains(dbg!(&path.segments)){continue;}
is the relevant line, but it's not clear what path.segments contains and relative to what base.
The text was updated successfully, but these errors were encountered:
Here we could note that the replacement path must be absolute (IIRC this is so that it is unambiguous, because the macro doesn't know in which path it's being called, but I'd have to check). It does already mention that it substitutes based on paths I think with "replaces any reference to the generated type at the path given by path with a reference to the path given by with" but perhaps we could make this clearer?
I think it'd be nice to also add here an example of how one can avoid using this attribute in some cases (the usual pattern here is to create a custom type and then impl From<runtime::GeneratedType> for MyType etc for easy conversion to/from your type from the generated one). It's always better to avoid where possible, since replacing generated types with custom types can easily go wrong (eg if the custom type is a different share to encoding/decoding fails, or if the custom type doesn't implement the traits that are required of it from other codegenned types).
Do you have any other thoughts on what we could clarify/tweak @drahnr?
It is not clear how to specify the substitute
syn::Path
s required as argument.A few things remain puzzling:
Ident
) themselves suffice for matching?is the relevant line, but it's not clear what
path.segments
contains and relative to what base.The text was updated successfully, but these errors were encountered: