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
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Opaque Result Type in Swift with Rust
Takuma Shimizu
March 27, 2019
More Decks by Takuma Shimizu
See All by Takuma Shimizu
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
200
Swift Attributes
hokuron
0
470
Peek in Calendar implementation of swift-foundation
hokuron
0
260
MVVM
hokuron
0
82
Summon Rust from Swift
hokuron
0
720
Generalized accessors
hokuron
0
93
Ownership of Swift as seen from iteration and Rust
hokuron
1
750
Clean Architecture 3
hokuron
0
76
Clean Architecture 2
hokuron
0
96
Other Decks in Programming
See All in Programming
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
110
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
4
2.8k
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
220
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
560
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
140
Building an Out-of-Order CPU
latte72
0
690
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
130
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
3
1k
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
業務時間外もAIに働いてもらう話
colorful12
3
10k
Deep dive into the select statement (GopherCon UK)
jespino
0
170
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
180
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
How GitHub (no longer) Works
holman
316
150k
KATA
mclloyd
PRO
35
15k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
A designer walks into a library…
pauljervisheath
211
25k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
330
Visualization
eitanlees
152
17k
Ethics towards AI in product and experience design
skipperchong
2
360
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
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