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
Takuma Shimizu
March 27, 2019
Programming
0
160
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
410
Peek in Calendar implementation of swift-foundation
hokuron
0
180
MVVM
hokuron
0
50
Summon Rust from Swift
hokuron
0
670
Generalized accessors
hokuron
0
81
Ownership of Swift as seen from iteration and Rust
hokuron
1
670
Clean Architecture 3
hokuron
0
54
Clean Architecture 2
hokuron
0
68
Create MLで犬と猫の肉球を学習
hokuron
0
100
Other Decks in Programming
See All in Programming
プロダクト志向なエンジニアがもう一歩先の価値を目指すために意識したこと
nealle
0
120
来たるべき 8.0 に備えて React 19 新機能と React Router 固有機能の取捨選択とすり合わせを考える
oukayuka
2
890
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
4
1k
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
280
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
680
エンジニア向け採用ピッチ資料
inusan
0
180
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
470
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
130
Select API from Kotlin Coroutine
jmatsu
1
220
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
180
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
140
Discover Metal 4
rei315
2
110
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Stop Working from a Prison Cell
hatefulcrawdad
270
20k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
Faster Mobile Websites
deanohume
307
31k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
Done Done
chrislema
184
16k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
Designing for humans not robots
tammielis
253
25k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.9k
Git: the NoSQL Database
bkeepers
PRO
430
65k
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