# \#generics

**URL:** https://forums.swift.org/tag/generics/10.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Conform Never to CustomStringConvertible](https://forums.swift.org/t/conform-never-to-customstringconvertible/90617)

<div class="topic-metadata">

**Author:** [@Dmitriy\_Ignatyev](https://forums.swift.org/u/Dmitriy_Ignatyev)\
**Replies:** 8\
**Last updated:** [November 10, 2026, 6:42pm UTC](https://forums.swift.org/t/conform-never-to-customstringconvertible/90617 "2026-11-10T18:42:56Z")

</div>

Introduction Following the precedent set by proposals like SE-0215 (Equatable/Hashable) and the more recent adoption of Codable for Never, I would like to pitch adding CustomStringConvertible and CustomDebugStringConvert…

---

## [Is this dumb? (using Integer Generic Parameter)](https://forums.swift.org/t/is-this-dumb-using-integer-generic-parameter/90401)

<div class="topic-metadata">

**Author:** [@Jae](https://forums.swift.org/u/Jae)\
**Replies:** 5\
**Last updated:** [November 6, 2026, 1:15pm UTC](https://forums.swift.org/t/is-this-dumb-using-integer-generic-parameter/90401 "2026-11-06T13:15:49Z")

</div>

I am writing some MIDI things using rtmidi C library, and I wanted to make it as static as possible. Unfortunately some MIDI messages like SysEx messages are arbitrary sized, so I had to either just use normal Array\<UInt…

---

## [NochUser For MacOS](https://forums.swift.org/t/nochuser-for-macos/90363)

<div class="topic-metadata">

**Author:** [@Magnumja](https://forums.swift.org/u/Magnumja)\
**Replies:** 0\
**Last updated:** [November 1, 2026, 7:28am UTC](https://forums.swift.org/t/nochuser-for-macos/90363 "2026-11-01T07:28:58Z")

</div>

:rocket: I built NotchUser, an open-source project for macOS Im sharing it with the Mac community and would love to hear your feedback. :unlocked: Open source :laptop: Built for macOS :handshake: Contributions and su…

---

## [Using SF-0011 with protocols](https://forums.swift.org/t/using-sf-0011-with-protocols/90115)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 0\
**Last updated:** [October 16, 2026, 10:19am UTC](https://forums.swift.org/t/using-sf-0011-with-protocols/90115 "2026-10-16T10:19:14Z")

</div>

Because conformance to AnyObject is not the same as subtyping of any AnyObject, SF-0011 does not allow to use existentials of AnyObject-constrained protocols as Subject, unless they are marked as @objc. protocol MySubje…

---

## [Unorthodox recursive data structures](https://forums.swift.org/t/unorthodox-recursive-data-structures/89885)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 2\
**Last updated:** [October 4, 2026, 10:28am UTC](https://forums.swift.org/t/unorthodox-recursive-data-structures/89885 "2026-10-04T10:28:48Z")

</div>

The topic name is a bit misleading as what's discussed here: could be mutable could be truly allocation free, could be stack allocated or in some cases uses heap allocation behind the curtains. could be truly dynamic (…

---

## [Is it possible to make a Functor protocol?](https://forums.swift.org/t/is-it-possible-to-make-a-functor-protocol/89758)

<div class="topic-metadata">

**Author:** [@Oleksii\_Skidan](https://forums.swift.org/u/Oleksii_Skidan)\
**Replies:** 11\
**Last updated:** [September 26, 2026, 7:54pm UTC](https://forums.swift.org/t/is-it-possible-to-make-a-functor-protocol/89758 "2026-09-26T19:54:38Z")

</div>

:waving\_hand: Hi everyone, Prelude I know that adjacent topics have been discussed on this forum over the years. Back in the day (Swift 3 era) everybody was waiting for generics to evolve. Now it's Swift 6 era, and it …

---

## [\[Pitch\] Dependent Integer Expressions in Generic Arguments](https://forums.swift.org/t/pitch-dependent-integer-expressions-in-generic-arguments/89170)

<div class="topic-metadata">

**Author:** [@Brennanium](https://forums.swift.org/u/Brennanium)\
**Replies:** 10\
**Last updated:** [September 2, 2026, 10:07pm UTC](https://forums.swift.org/t/pitch-dependent-integer-expressions-in-generic-arguments/89170 "2026-09-02T22:07:41Z")

</div>

Hey all, I've been working on several small prototypes of this ever since SE-0452 originally introduced integer generic parameters and mentioned arithmetic generics in the "Future directions" section. Since SE-0531 (lit…

---

## [Optimystic: open-source visual acuity app built with SwiftUI](https://forums.swift.org/t/optimystic-open-source-visual-acuity-app-built-with-swiftui/89265)

<div class="topic-metadata">

**Author:** [@nayanbhatia311](https://forums.swift.org/u/nayanbhatia311)\
**Replies:** 0\
**Last updated:** [August 29, 2026, 2:45am UTC](https://forums.swift.org/t/optimystic-open-source-visual-acuity-app-built-with-swiftui/89265 "2026-08-29T02:45:14Z")

</div>

Rebuilt Optimystic, a visual-acuity testing app my team originally made as an undergrad project in 2019–20. This version is a native iOS/SwiftUI rebuild and can run on one device, pair two Apple devices as controller + …

---

## [Protocols in generics would be so useful](https://forums.swift.org/t/protocols-in-generics-would-be-so-useful/88768)

<div class="topic-metadata">

**Author:** [@No\_Pen\_3825](https://forums.swift.org/u/No_Pen_3825)\
**Replies:** 0\
**Last updated:** [August 4, 2026, 3:21pm UTC](https://forums.swift.org/t/protocols-in-generics-would-be-so-useful/88768 "2026-08-04T15:21:15Z")

</div>

I want to write something like below (a type safe components container where I can swap the kind of protocol), but it'd require a generic be a protocol rather than something concrete. I believe the closest I can nativel…

---

## [Can we require StringProtocol.UTF8View be a BidirectionalCollection?](https://forums.swift.org/t/can-we-require-stringprotocol-utf8view-be-a-bidirectionalcollection/44951)

<div class="topic-metadata">

**Author:** [@Karl](https://forums.swift.org/u/Karl)\
**Replies:** 1\
**Last updated:** [July 25, 2026, 6:31am UTC](https://forums.swift.org/t/can-we-require-stringprotocol-utf8view-be-a-bidirectionalcollection/44951 "2026-07-25T06:31:53Z")

</div>

StringProtocol.UTF8View only requires Collection conformance, even though StringProtocol itself, as well as the UTF16View and UnicodeScalarView, are BidirectionalCollections. The actual UTF8Views for String and Substring…

---

## [Is Swift Embedded ready to be used in simple maker projects for embedded beginners?](https://forums.swift.org/t/is-swift-embedded-ready-to-be-used-in-simple-maker-projects-for-embedded-beginners/88351)

<div class="topic-metadata">

**Author:** [@tscholze](https://forums.swift.org/u/tscholze)\
**Replies:** 4\
**Last updated:** [July 20, 2026, 8:28am UTC](https://forums.swift.org/t/is-swift-embedded-ready-to-be-used-in-simple-maker-projects-for-embedded-beginners/88351 "2026-07-20T08:28:30Z")

</div>

Hi guys and thanks for pushing Swift Embedded. I am for more than 15 years a Swift / ObjC developer and I tinker heavily around with Raspberry Pi projects, simple robots using the Pi and .NET and so on. Now I want to c…

---

## [Protocol existential wrappers in C++ generated header](https://forums.swift.org/t/protocol-existential-wrappers-in-c-generated-header/88116)

<div class="topic-metadata">

**Author:** [@AdamCmiel](https://forums.swift.org/u/AdamCmiel)\
**Replies:** 4\
**Last updated:** [July 10, 2026, 6:36pm UTC](https://forums.swift.org/t/protocol-existential-wrappers-in-c-generated-header/88116 "2026-07-10T18:36:01Z")

</div>

Motivation Swift's C++ interop can represent concrete types on both sides of the boundary. Classes get RefCountedClass wrappers with retain/release lifecycle. Structs get value-type wrappers with VWT-delegated copy and d…

---

## [Is there a difference between using \`any\` and \`some\` if I'm assigning the value to an existential type in the end anyway?](https://forums.swift.org/t/is-there-a-difference-between-using-any-and-some-if-im-assigning-the-value-to-an-existential-type-in-the-end-anyway/87768)

<div class="topic-metadata">

**Author:** [@atifdev10](https://forums.swift.org/u/atifdev10)\
**Replies:** 12\
**Last updated:** [July 2, 2026, 7:47am UTC](https://forums.swift.org/t/is-there-a-difference-between-using-any-and-some-if-im-assigning-the-value-to-an-existential-type-in-the-end-anyway/87768 "2026-07-02T07:47:57Z")

</div>

For example, are these initialisers below semantically mean the same thing? struct Foo { var anyHashable: any Hashable init(\_ value: some Hashable) { anyHashable = value } init(\_ value: any Has…

---

## [Making makeshift/partial generic isolation using generic global actors](https://forums.swift.org/t/making-makeshift-partial-generic-isolation-using-generic-global-actors/87552)

<div class="topic-metadata">

**Author:** [@atifdev10](https://forums.swift.org/u/atifdev10)\
**Replies:** 0\
**Last updated:** [June 21, 2026, 8:50am UTC](https://forums.swift.org/t/making-makeshift-partial-generic-isolation-using-generic-global-actors/87552 "2026-06-21T08:50:13Z")

</div>

One day, while messing with global actors, I found out that they can have generic parameters. @globalActor struct GenericGlobalActor\<T\> { static var shared: MainActor { .shared } } @GenericGlobalActor\<Int\> func foo…

---

## [\[Pitch\] Boolean Generics](https://forums.swift.org/t/pitch-boolean-generics/86733)

<div class="topic-metadata">

**Author:** [@hbaker](https://forums.swift.org/u/hbaker)\
**Replies:** 7\
**Last updated:** [May 18, 2026, 2:18am UTC](https://forums.swift.org/t/pitch-boolean-generics/86733 "2026-05-18T02:18:31Z")

</div>

Hello Swift Evolution, Right now, with integer generics, we can represent fixed-size collections, but we don’t have any way of restricting the possible values to only a specific set. I would like to propose that we exte…

---

## [Introducing PropertyTestingKit: A swift-testing friendly coverage-guided fuzzer](https://forums.swift.org/t/introducing-propertytestingkit-a-swift-testing-friendly-coverage-guided-fuzzer/86705)

<div class="topic-metadata">

**Author:** [@alex-reilly-dd](https://forums.swift.org/u/alex-reilly-dd)\
**Replies:** 1\
**Last updated:** [May 13, 2026, 9:20pm UTC](https://forums.swift.org/t/introducing-propertytestingkit-a-swift-testing-friendly-coverage-guided-fuzzer/86705 "2026-05-13T21:20:00Z")

</div>

Today I'm releasing the first alpha of PropertyTestingKit! PropertyTestingKit is a coverage-guided fuzzer available for Swift. @Test func testDatabaseQuery() async throws { try await fuzz { table, limit in …

---

## [Can a generic item depend on a generic template instead of a generic type?](https://forums.swift.org/t/can-a-generic-item-depend-on-a-generic-template-instead-of-a-generic-type/86684)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 2\
**Last updated:** [May 12, 2026, 10:51pm UTC](https://forums.swift.org/t/can-a-generic-item-depend-on-a-generic-template-instead-of-a-generic-type/86684 "2026-05-12T22:51:38Z")

</div>

Here's what I want to do: extension Sequence\<T\> where Element == SortedSetElement\<T\> { //... } I get an error that T is not in scope. The first generic depends on a specific instantiation of the second, but the firs…

---

## [Swift 6 strict concurrency + UIKit DiffableDataSource: Main actor-isolated conformance ... cannot satisfy Sendable type parameter](https://forums.swift.org/t/swift-6-strict-concurrency-uikit-diffabledatasource-main-actor-isolated-conformance-cannot-satisfy-sendable-type-parameter/86272)

<div class="topic-metadata">

**Author:** [@BoseSj](https://forums.swift.org/u/BoseSj)\
**Replies:** 5\
**Last updated:** [April 27, 2026, 10:19am UTC](https://forums.swift.org/t/swift-6-strict-concurrency-uikit-diffabledatasource-main-actor-isolated-conformance-cannot-satisfy-sendable-type-parameter/86272 "2026-04-27T10:19:35Z")

</div>

Hi all, I’m hitting what looks like a strict-concurrency isolation issue when using UITable​View​Diffable​Data​Source in a UIKit app under Swift 6 mode. I can work around it, but I want to confirm the correct model and…

---

## [Claude Code Skills for Server-Side Swift & Xcode Cloud — 15 open-source skill files for Vapor, Hummingbird, and CI/CD](https://forums.swift.org/t/claude-code-skills-for-server-side-swift-xcode-cloud-15-open-source-skill-files-for-vapor-hummingbird-and-ci-cd/85851)

<div class="topic-metadata">

**Author:** [@aistobascistox](https://forums.swift.org/u/aistobascistox)\
**Replies:** 2\
**Last updated:** [April 19, 2026, 5:48am UTC](https://forums.swift.org/t/claude-code-skills-for-server-side-swift-xcode-cloud-15-open-source-skill-files-for-vapor-hummingbird-and-ci-cd/85851 "2026-04-19T05:48:57Z")

</div>

Hello everyone, I've been using Claude Code for iOS development and recently went looking for skills that could help with server-side Swift… As I couldn't find a single skill for server-side Swift. Not for Vapor, not fo…

---

## [Extensions on nested generics with protocols](https://forums.swift.org/t/extensions-on-nested-generics-with-protocols/85954)

<div class="topic-metadata">

**Author:** [@bnickel](https://forums.swift.org/u/bnickel)\
**Replies:** 3\
**Last updated:** [April 10, 2026, 9:31pm UTC](https://forums.swift.org/t/extensions-on-nested-generics-with-protocols/85954 "2026-04-10T21:31:13Z")

</div>

If I have an array where the elements conform to MyProtocol and want to create an extension for it, I can do something along the lines of: extension Array where Element: MyProtocol { func myFunc() { ... } } Is it pos…

---

## [Conform to generic protocol twice](https://forums.swift.org/t/conform-to-generic-protocol-twice/85402)

<div class="topic-metadata">

**Author:** [@a7medev](https://forums.swift.org/u/a7medev)\
**Replies:** 9\
**Last updated:** [March 18, 2026, 8:32am UTC](https://forums.swift.org/t/conform-to-generic-protocol-twice/85402 "2026-03-18T08:32:03Z")

</div>

I have the following generic protocol: protocol EventListener\<Event\> { associatedtype Event func onEvent(\_ event: Event) } Some classes can receive different events, so they should conform to EventListener mul…

---

## [Typed throws do not infer type in generic type-throwing functions](https://forums.swift.org/t/typed-throws-do-not-infer-type-in-generic-type-throwing-functions/79036)

<div class="topic-metadata">

**Author:** [@hibernat](https://forums.swift.org/u/hibernat)\
**Replies:** 12\
**Last updated:** [February 28, 2026, 3:04am UTC](https://forums.swift.org/t/typed-throws-do-not-infer-type-in-generic-type-throwing-functions/79036 "2026-02-28T03:04:01Z")

</div>

Typed throws in generic function are not typed throws @Sendable public func withSingleTaskInThrowingTaskGroup\<Returning: Sendable, ThrowsError: Error\>( cancellationError: ThrowsError, perform: @escaping @Sendabl…

---

## [Xcode Invaild declaration of](https://forums.swift.org/t/xcode-invaild-declaration-of/84739)

<div class="topic-metadata">

**Author:** [@mrky25](https://forums.swift.org/u/mrky25)\
**Replies:** 3\
**Last updated:** [February 14, 2026, 10:23pm UTC](https://forums.swift.org/t/xcode-invaild-declaration-of/84739 "2026-02-14T22:23:49Z")

</div>

I’m building an app using Xcode, and I’m running into Invaild declaration of error. I checked for duplicate files, but there are none. I tried to rename the files that didn’t work, and changed them back. It worked before…

---

## [Generics type constraints for beginners](https://forums.swift.org/t/generics-type-constraints-for-beginners/84572)

<div class="topic-metadata">

**Author:** [@belakiss](https://forums.swift.org/u/belakiss)\
**Replies:** 4\
**Last updated:** [February 6, 2026, 10:24am UTC](https://forums.swift.org/t/generics-type-constraints-for-beginners/84572 "2026-02-06T10:24:41Z")

</div>

Noob-ish question. Say I have a generic datatype defined like so: struct ChartDataset\<XT,YT\>: Identifiable { var data: \[ChartDatum\<XT,YT\>\] } and I would like to constrain it to Date and Double (for use as ChartData…

---

## [Parameterized Extensions](https://forums.swift.org/t/parameterized-extensions/25563)

<div class="topic-metadata">

**Author:** [@Alejandro](https://forums.swift.org/u/Alejandro)\
**Replies:** 70\
**Last updated:** [February 4, 2026, 5:39pm UTC](https://forums.swift.org/t/parameterized-extensions/25563 "2026-02-04T17:39:18Z")

</div>

Parameterized Extensions Proposal: SE-NNNN Author: Alejandro Alonso Review Manager: TBD Status: Awaiting Review Implementation: apple/swift#25263 Introduction Hello Evolution, this is my first draft at a proposal for P…

---

## [Coercing \`any\` into \`some\`](https://forums.swift.org/t/coercing-any-into-some/84213)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 1\
**Last updated:** [January 19, 2026, 4:25pm UTC](https://forums.swift.org/t/coercing-any-into-some/84213 "2026-01-19T16:25:05Z")

</div>

In this fragment I am getting an error: protocol P: Equatable {} struct S: P {} func foo(\_ value: some P) {} let a: Any = S() foo(a as! any P) // ❌ Type 'any P' cannot conform to 'P' I suppose it is expected behaviour…

---

## [I reimplemented Foundation's JSONEncoder and made it 33% faster using compile-time strategy dispatch](https://forums.swift.org/t/i-reimplemented-foundations-jsonencoder-and-made-it-33-faster-using-compile-time-strategy-dispatch/84195)

<div class="topic-metadata">

**Author:** [@couchdeveloper](https://forums.swift.org/u/couchdeveloper)\
**Replies:** 7\
**Last updated:** [January 19, 2026, 7:55am UTC](https://forums.swift.org/t/i-reimplemented-foundations-jsonencoder-and-made-it-33-faster-using-compile-time-strategy-dispatch/84195 "2026-01-19T07:55:19Z")

</div>

I recently explored whether Swift's type system and compiler could eliminate runtime overhead in encoding, and the results were surprising: a 33% performance improvement over Foundation's JSONEncoder using clean, maintai…

---

## [\[Pitch\] Concurrent Async Iteration over Parameter Packs](https://forums.swift.org/t/pitch-concurrent-async-iteration-over-parameter-packs/84066)

<div class="topic-metadata">

**Author:** [@Luminaron](https://forums.swift.org/u/Luminaron)\
**Replies:** 0\
**Last updated:** [January 11, 2026, 7:01am UTC](https://forums.swift.org/t/pitch-concurrent-async-iteration-over-parameter-packs/84066 "2026-01-11T07:01:05Z")

</div>

Introduction When using parameter packs and async functions, I identified some potential gaps in the current syntax for concurrent iteration over parameter packs. Motivation Consider fetching data with an async function…

---

## [Lowering \`OpaqueValueExpr\`-based abstraction as a closure](https://forums.swift.org/t/lowering-opaquevalueexpr-based-abstraction-as-a-closure/83955)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 2\
**Last updated:** [January 6, 2026, 10:33am UTC](https://forums.swift.org/t/lowering-opaquevalueexpr-based-abstraction-as-a-closure/83955 "2026-01-06T10:33:39Z")

</div>

I'm processing @kavon's feedback in https://github.com/swiftlang/swift/pull/84789. I'm trying to lower CollectionUpcastConversionExpr::ConversionPair as a closure with correct abstraction pattern. There is SILGenFunctio…

---

## [How to use sub protocol in generic type that use protocol?](https://forums.swift.org/t/how-to-use-sub-protocol-in-generic-type-that-use-protocol/83486)

<div class="topic-metadata">

**Author:** [@miku1958](https://forums.swift.org/u/miku1958)\
**Replies:** 15\
**Last updated:** [December 3, 2025, 10:51pm UTC](https://forums.swift.org/t/how-to-use-sub-protocol-in-generic-type-that-use-protocol/83486 "2025-12-03T22:51:38Z")

</div>

Hello everyone, I have a type like this and I want the Model and ObjectProtocol to be strongly bound: final public class Model\<Object\> where Object: ObjectProtocol { var object: Object public init(object: Object) { …

[Next page](https://forums.swift.org/tag/generics/10.md?match_all_tags=true&page=1&tags%5B%5D=generics)
