Month: July 2026

Why Swift’s `borrowing` and `consuming` Keywords Change How You Design Value Types

Most Swift developers operate on a simple mental model: structs get copied, classes get referenced, the compiler handles the rest. That model has held up since Swift 1.0 — mostly. But SE-0377 and SE-0395 introduce borrowing and consuming parameter ownership modifiers, and the model no longer holds without qualification. These keywords aren’t ergonomic shortcuts. They

How to Implement Custom Swift Collections

Swift’s standard library gives you Array, Set, Dictionary, and their lazy or slice variants. They’re solid. But production apps have a way of outgrowing them. Maybe you need a ring buffer for a real‑time audio pipeline, an ordered set that remembers insertion order while blocking duplicates, or a sparse grid that doesn’t burn memory on

Implementing Custom Swift Collections: Protocols, Performance, and Pitfalls

Why Build a Custom Collection in Swift? A custom Swift collection is any type that conforms to the Collection protocol, giving it first-class access to iteration, subscripting, and dozens of standard library algorithms. For professional developers working on iOS, macOS, watchOS, or tvOS apps, rolling your own collection isn’t about reinventing Array—it’s about modeling domain-specific

Building Custom Swift Collections: A Practical Guide to Sequence and Collection Protocols

Swift’s standard library hands you Array, Set, and Dictionary—solid workhorses that cover most day-to-day needs. But the moment you reach for a ring buffer, a sorted bag, or a lazy evaluation pipeline, you’re staring down the barrel of a custom collection. A custom Swift collection is any type that conforms to the Collection protocol, inherits

Crafting Custom Swift Collections: Protocols, Performance, and Real-World Patterns

Why Build Your Own Collection? Swift’s Array, Set, and Dictionary are workhorses. They’re fast, well-tested, and handle the vast majority of data storage tasks you’ll encounter. But sometimes, a general-purpose container doesn’t quite fit. Maybe you need a fixed-size window that automatically discards old data, or a structure that enforces strict ordering rules at the

How to Read Swift SIL to Verify Compiler Optimizations

Every Swift developer has written a generic function, added @inlinable, or used a protocol witness, and then wondered: did the compiler actually do what I expected? Did it specialize the generic? Did it devirtualize the call? Did it eliminate the retain cycle I suspect is there? The Swift compiler’s intermediate representation—SIL, or Swift Intermediate Language—is