Unsized section of request_lt! macro can not contain Option<T> fields, as it prepends all types with reference token &'a. This is intentional, as only macro system doesn't allow to operate on lifetimes as a separate token, so I can't pass lifetime into macro directly.
Due to hygiene restrictions I either must pass field type lifetimes and struct lifetime from outside, or generate all of them inside the macro. Being unable to pass lifetimes into macro, I opted to the second option.
The problem is if the unsized field type is for example Option<str>, the generated field type will be &'a Option<str>, which would not work. The real type should be Option<&'a str>.
One of the possible solutions would be to make all unsized fields optional, so macro will just wrap all references in Option<&'a ...>. This can be somewhat unexpected to an unaware contributor, but it doesn't add any overhead, as Option<&T> is the same as &T, and None variant is just encoded as NULL pointer.
Unsized section of
request_lt!macro can not containOption<T>fields, as it prepends all types with reference token&'a. This is intentional, as only macro system doesn't allow to operate on lifetimes as a separate token, so I can't pass lifetime into macro directly.Due to hygiene restrictions I either must pass field type lifetimes and struct lifetime from outside, or generate all of them inside the macro. Being unable to pass lifetimes into macro, I opted to the second option.
The problem is if the unsized field type is for example
Option<str>, the generated field type will be&'a Option<str>, which would not work. The real type should beOption<&'a str>.One of the possible solutions would be to make all unsized fields optional, so macro will just wrap all references in
Option<&'a ...>. This can be somewhat unexpected to an unaware contributor, but it doesn't add any overhead, asOption<&T>is the same as&T, andNonevariant is just encoded as NULL pointer.