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
I'm running into an issue and wonder if I'm missing something or if this is by design. I have an array of transparent structs that I'd like to return to Swift. I'd be fine with returning a RustVec, but eventually I want a Swift array of FfiThings structs.
Right now my setup looks like this...
// Thing is a Rust struct that I also expose to wasm, so I'd prefer// not to move it into `mod ffi`.implFrom<Thing>for ffi::FfiThing{
...
}fnclone_and_into(layers:Vec<Layer>) -> Vec<ffi::FfiLayer>{
layers.into_iter().map(|l| l.into()).collect()}#[swift_bridge::bridge]mod ffi {#[swift_bridge(swift_repr = "struct")]structFfiThing{
... simple properties ...
}extern"Rust"{// `clone_and_into` is necessary because without it,// swift-bridge says that Vec isn't clone-able.#[swift_bridge(return_with = clone_and_into)]fnget_things() -> Vec<FfiThing>;}}
While the above works fine from a Rust perspective... when I compile Swift the return type is RustVec which doesn't compile because FfiThing isn't vectorizeable. This makes sense to me, since RustVecs are shallow views into Rust, and I want to copy FfiThing over to Swift.
Do you have a recommended path here? Is there a way, for example, to tell the swift-bridge that I want an Array in Swift and not a RustVec? The array and structs in question will be read frequently from Swift, so I really do just want to copy all the data over to Swift rather than repeatedly call into Rust.
The text was updated successfully, but these errors were encountered:
Hi again :)
I'm running into an issue and wonder if I'm missing something or if this is by design. I have an array of transparent structs that I'd like to return to Swift. I'd be fine with returning a RustVec, but eventually I want a Swift array of FfiThings structs.
Right now my setup looks like this...
While the above works fine from a Rust perspective... when I compile Swift the return type is RustVec which doesn't compile because
FfiThing
isn't vectorizeable. This makes sense to me, since RustVecs are shallow views into Rust, and I want to copy FfiThing over to Swift.Do you have a recommended path here? Is there a way, for example, to tell the swift-bridge that I want an Array in Swift and not a RustVec? The array and structs in question will be read frequently from Swift, so I really do just want to copy all the data over to Swift rather than repeatedly call into Rust.
The text was updated successfully, but these errors were encountered: