swift → rust → wasm
tswift parses, type-checks, and runs Swift entirely in Rust — no LLVM, no Clang, no Swift toolchain. The same Rust binary compiles to WebAssembly so you can run Swift code right here in the browser, at fraction of the size for full Swift.
Ready.
A pure-Rust pipeline from Swift source to output, with no C dependencies.
Pure-Rust lexer → AST → parser → semantic analysis. No C, no LLVM, no unsafe code.
Tree-walking interpreter with ARC via Rc, copy-on-write value semantics, and native closures.
Native Rust implementations of Swift's stdlib, with Foundation and SwiftUI on the roadmap.
tswift covers 8 tiers of the Swift 6.3 language surface, plus stdlib and Foundation.
Rust's ownership model maps onto Swift's memory semantics surprisingly well.
Swift's ARC becomes Rc<RefCell<T>> in Rust. Value-type copy-on-write becomes Rc::make_mut. Deterministic deinit maps to Drop. No unsafe anywhere in the stack.
The same Rust crate compiles to native (fast CLI) and towasm32-unknown-unknown (browser). No platform-specific shims — the interpreter just runs.
| Swift | Rust |
|---|---|
Value-type CoW | Rc::clone + Rc::make_mut |
class ARC | Rc<RefCell<Object>> |
deinit | Drop at strong-count 0 |
weak (zeroing) | rc::Weak + .upgrade() |
overflow trap | checked_add / wrapping_add |
UTF-8 String | Rust String |
Every feature has a .swift + .expected golden fixture. The harness runs each through the CLI and diffs stdout. 53+ fixtures pass end-to-end today.