Standard Library

The Swift standard library provides the runtime behaviour for all built-in types and protocols. tswift implements these entirely in Rust inside tswift-std.

The frontend provides type shapes; tswift-std provides the behaviour.

Legend: ✅ Done · 🟡 Partial · ⬜ Todo


Overall coverage

Standard Library73% (19/26)

Core Value Types

Core value types75% (6/8)
Status Type Notes
Int, UInt family (all widths) Overflow-trapping + &+/&-/&* wrapping
Float, Double IEEE 754, math functions
Bool
🟡 String (UTF-8, NFC, views) + Character Most APIs work; CharacterView, UnicodeScalarView partial
🟡 Substring Slicing works; full index arithmetic incomplete
Optional<Wrapped> Full — binding, chaining, coalescing, patterns
Range / ClosedRange / Stride For-in, contains, count, overlaps
Tuples as first-class stdlib types Runtime supports tuples; stdlib protocols not wired

Collections

Collections80% (4/5)
Status Type Notes
Array<Element> + CoW append, insert, remove, sorted, map/filter/reduce, slicing
Dictionary<Key,Value> + CoW keys, values, merging, filter, mapValues
Set<Element> + CoW union, intersection, subtracting, symmetricDifference
ContiguousArray / ArraySlice Backed by Array in the runtime
isKnownUniquelyReferenced CoW correctness helper — not exposed

Protocols That Drive the Language

Key protocols70% (7/10)
Status Protocol Notes
Equatable / Hashable / Comparable Synthesised for structs/enums with synthesised conformance
Sequence / IteratorProtocol Custom sequences via makeIterator()
Collection / BidirectionalCollection / RandomAccessCollection Index arithmetic not yet fully implemented
RangeReplaceableCollection
ExpressibleBy*Literal All literal-conversion protocols
CustomStringConvertible / CustomDebugStringConvertible
RawRepresentable / CaseIterable Enum conformances synthesised
Codable / Encodable / Decodable JSON encode/decode via synthesised CodingKeys
Identifiable
Sendable Accepted by parser; not statically checked
AsyncSequence / AsyncIteratorProtocol for await works; custom AsyncSequence conformances partial

Free Functions & Utilities

Free functions86% (6/7)
Status API Notes
print / debugPrint / dump Streaming to stdout
map/filter/reduce/flatMap/compactMap/sorted/zip All HOF on sequences
assert/precondition/fatalError/assertionFailure Trapping semantics
min/max/abs/stride/zip/swap
Result<Success, Failure> Both cases, map, flatMap, mapError
MemoryLayout<T> size, stride, alignment
Unsafe*Pointer family Requires unsafe Rust; out of scope for now

What’s next

The highest-impact missing pieces:

  1. Collection protocol conformances — needed for custom types to slot into for-in, count, first, last, index subscripting.
  2. String index arithmeticString.Index, index(before:), index(after:), index(_:offsetBy:) needed for full character-level manipulation.
  3. AsyncSequence — needed to implement for await over custom types.

To see how these map to GitHub issues, visit the issue tracker.