Simplify construction of Ref and OutRef directly
#3730
Merged
+148
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#3025 added the the
RefandOutReftypes that represent borrowed types, providing the same memory layout but also offer lifetime management and conveniences to make dealing with in and out parameters safe and convenient:This made it much simpler to implement ABIs like
DllGetActivationFactorybut didn't provide much in the way of calling functions with those same ABI types. The thinking was that these would typically be called from some other language like C++, which is typically the case.In order to make it easier to define ABI boundaries directly in Rust that might be called from Rust itself, this update adds some conveniences to safely construct
RefandOutReftypes from local Rust types again with the same memory layout and lifetime. This is mainly just adding more convenientFromimplementations forRefandDefaultimplementations for both. The tests illustrate how this might be used.