Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Opaque Result Type in Swift with Rust
Search
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
440
Peek in Calendar implementation of swift-foundation
hokuron
0
200
MVVM
hokuron
0
51
Summon Rust from Swift
hokuron
0
680
Generalized accessors
hokuron
0
82
Ownership of Swift as seen from iteration and Rust
hokuron
1
690
Clean Architecture 3
hokuron
0
57
Clean Architecture 2
hokuron
0
74
Create MLで犬と猫の肉球を学習
hokuron
0
100
Other Decks in Programming
See All in Programming
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
180
配送計画の均等化機能を提供する取り組みについて(⽩⾦鉱業 Meetup Vol.21@六本⽊(数理最適化編))
izu_nori
0
120
CSC509 Lecture 14
javiergs
PRO
0
220
251126 TestState APIってなんだっけ?Step Functionsテストどう変わる?
east_takumi
0
290
20 years of Symfony, what's next?
fabpot
2
300
エディターってAIで操作できるんだぜ
kis9a
0
620
Level up your Gemini CLI - D&D Style!
palladius
1
160
非同期処理の迷宮を抜ける: 初学者がつまづく構造的な原因
pd1xx
1
420
UIデザインに役立つ 2025年の最新CSS / The Latest CSS for UI Design 2025
clockmaker
16
6.4k
これだけで丸わかり!LangChain v1.0 アップデートまとめ
os1ma
6
1.2k
認証・認可の基本を学ぼう前編
kouyuume
0
150
FluorTracer / RayTracingCamp11
kugimasa
0
180
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1371
200k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
A Tale of Four Properties
chriscoyier
162
23k
We Have a Design System, Now What?
morganepeng
54
7.9k
Agile that works and the tools we love
rasmusluckow
331
21k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Thoughts on Productivity
jonyablonski
73
4.9k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
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