Change the __FromRaw() and __IntoRaw() conversion functions to take an out parameter instead of directly returning their output. This allows overload resolution to take the output type into account, removing the need for a unique C# type corresponding to every Rust type used in an ABI boundary.
For example, we previously needed a separate RustBool struct so that we could have separate overloads of __FromRaw for byte and bool (since both u8 and bool are represented as byte on the C# side). Now, we can have multiple overloads of __FromRaw that take byte as the input as long as their output types differ.
This change complicates the generated code for functions, since we can no longer chain functions together as easily. However, the extra complication in the generated code is worth it, since this change drastically reduces the amount of monomorphization that we will need to perform when handling generic types (e.g. collection types).
Change the
__FromRaw()
and__IntoRaw()
conversion functions to take anout
parameter instead of directly returning their output. This allows overload resolution to take the output type into account, removing the need for a unique C# type corresponding to every Rust type used in an ABI boundary.For example, we previously needed a separate
RustBool
struct so that we could have separate overloads of__FromRaw
forbyte
andbool
(since bothu8
andbool
are represented asbyte
on the C# side). Now, we can have multiple overloads of__FromRaw
that takebyte
as the input as long as their output types differ.This change complicates the generated code for functions, since we can no longer chain functions together as easily. However, the extra complication in the generated code is worth it, since this change drastically reduces the amount of monomorphization that we will need to perform when handling generic types (e.g. collection types).