Built In Types

In addition to allowing you to share your own custom types between Rust and Swift, swift-bridge comes with support for a number of Rust and Swift standard library types.

name in Rustname in Swiftnotes
u8, i8, u16, i16... etcUInt8, Int8, UInt16, Int16 ... etc
boolBool
String, &String, &mut StringRustString, RustStringRef, RustStringRefMut
&strRustStr
Vec<T>RustVec<T>
SwiftArray<T>Array<T>Not yet implemented
&[T]Not yet implemented
&mut [T]Not yet implemented
Box<T>Not yet implemented
Box<dyn FnOnce(A,B,C) -> D>(A, B, C) -> DPassing from Rust to Swift is supported, but Swift to Rust is not yet implemented.
Box<dyn Fn(A,B,C) -> D>(A, B, C) -> DNot yet implemented
Arc<T>Not yet implemented
[T; N]Not yet implemented
*const TUnsafePointer<T>
*mut TUnsafeMutablePointer<T>
Option<T>Optional<T>
fn x() -> Result<T, E>func x() throws -> T
fn x(arg: Result<T, E>)func x(arg: RustResult<T, E>)
(A, B, C, ...)(A, B, C, ...)
Have a Rust standard library type in mind?
Open an issue!
Have a Swift standard library type in mind?
Open an issue!