randomPoison / cs-bindgen

Experiment in using Rust to build a library that can be loaded by Unity across multiple platforms
4 stars 0 forks source link

Support passing list types to Rust #63

Closed randomPoison closed 4 years ago

randomPoison commented 4 years ago

This PR implements the conversion logic on the C# side for passing lists of values to Rust functions. Most of the functionality on the Rust side was already in place, the only addition was that we now export functions for taking a &[T::Abi] and converting it into a Vec<T>. This allows the C# side to "allocate" a Rust Vec when one is expected by an exported Rust function (or inside the raw representation of a type being passed to an exported function) while avoiding the tricky questions that arise if we try to pass a RawVec that wasn't allocated on the Rust side. The main drawback to this approach is that it means an extra call into Rust for each Vec that needs to be created, though we don't yet know how expense the cross-language calls are yet.