Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Opaque Result Type in Swift with Rust
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Takuma Shimizu
March 27, 2019
Programming
0
170
Opaque Result Type in Swift with Rust
Takuma Shimizu
March 27, 2019
Tweet
Share
More Decks by Takuma Shimizu
See All by Takuma Shimizu
Swift Attributes
hokuron
0
450
Peek in Calendar implementation of swift-foundation
hokuron
0
220
MVVM
hokuron
0
53
Summon Rust from Swift
hokuron
0
690
Generalized accessors
hokuron
0
83
Ownership of Swift as seen from iteration and Rust
hokuron
1
700
Clean Architecture 3
hokuron
0
61
Clean Architecture 2
hokuron
0
79
Create MLで犬と猫の肉球を学習
hokuron
0
100
Other Decks in Programming
See All in Programming
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
670
Denoのセキュリティに関する仕組みの紹介 (toranoana.deno #23)
uki00a
0
270
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
180
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
2.6k
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
6k
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
130
Oxlintはいいぞ
yug1224
5
1.2k
AgentCoreとHuman in the Loop
har1101
5
200
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
700
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
500
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.7k
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
0
50
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Deep Space Network (abreviated)
tonyrice
0
37
Code Reviewing Like a Champion
maltzj
527
40k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
2.9k
Odyssey Design
rkendrick25
PRO
1
480
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
100
AI Search: Where Are We & What Can We Do About It?
aleyda
0
6.9k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
310
What does AI have to do with Human Rights?
axbom
PRO
0
2k
Transcript
Opaque Result Type in Swift with Rust
『Swift 5.1 に導入されそうな Opaque Result Type と は何か』 https://qiita.com/koher/items/338d2f2d0c4731e35 08f
リバースジェネリクス 通常のジェネリクス func useAnimal<A: Animal>(_ animal: A) { animal.foo() }
メソッド名に型引数を宣言 引数で型変数を利用 呼び出し側が型引数に対応する具象型を決定
リバースジェネリクス リバースジェネリクス func makeAnimal() -> <A: Animal> A { return
Cat() } メソッドシグネチャの後に型引数を宣言 返却値の型が型変数 実装側が型引数に対応する具象型を決定
Opaque Result Type some Animal を 返却値の型として利用 → リバースジェネリクス メソッド引数として利用
→ 通常のジェネリクスと同義 !!????
ジェネリクス func useAnimal<A: Animal>(_ animal: A) ↓ 型システム的な表現にすると ∀ A.
(func(A: Animal) -> ()) Opaque type func useAnimal(_ animal: some Animal) ↓ 型システム的な表現にすると (∃ A. A: Animal) -> ()
∀ A. (func(A: Animal) -> ()) ターンエーガンダムみたいななんかよく分からん記号 が、メソッドの引数から返却値まで全体にかかってい る。 (∃
A. A: Animal) -> () カタカナの「ヨ」みたいななんかよく分からん記号 は、出現場所( メソッド引数) だけにかかっている。 A. A: Animal の部分は一致している
つまり ∀ A. (func(A: Animal) -> ()) ⇔ (∃ A.
A: Animal) -> () という関係が成り立つ。 メソッド引数として利用した場合、通常のジェネリク スと同義 → 同じではないが、同形をとる
なぜプロトコル型に パフォーマンス上のロスがあるのか
Demo with Rust