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 Rust | name in Swift | notes |
|---|---|---|
| u8, i8, u16, i16... etc | UInt8, Int8, UInt16, Int16 ... etc | |
| bool | Bool | |
| String, &String, &mut String | RustString, RustStringRef, RustStringRefMut | |
| &str | RustStr | |
| 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) -> D | Passing from Rust to Swift is supported, but Swift to Rust is not yet implemented. |
| Box<dyn Fn(A,B,C) -> D> | (A, B, C) -> D | Not yet implemented |
| Arc<T> | Not yet implemented | |
| [T; N] | Not yet implemented | |
| *const T | UnsafePointer<T> | |
| *mut T | UnsafeMutablePointer<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! |