Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
690
Generalized accessors
hokuron
0
82
Ownership of Swift as seen from iteration and Rust
hokuron
1
690
Clean Architecture 3
hokuron
0
58
Clean Architecture 2
hokuron
0
76
Create MLで犬と猫の肉球を学習
hokuron
0
100
Other Decks in Programming
See All in Programming
20 years of Symfony, what's next?
fabpot
2
360
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
430
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
160
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
7
2.4k
Integrating WordPress and Symfony
alexandresalome
0
150
なあ兄弟、 余白の意味を考えてから UI実装してくれ!
ktcryomm
11
11k
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
3.5k
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
160
DSPy Meetup Tokyo #1 - はじめてのDSPy
masahiro_nishimi
1
170
認証・認可の基本を学ぼう前編
kouyuume
0
200
これだけで丸わかり!LangChain v1.0 アップデートまとめ
os1ma
6
1.8k
AIコーディングエージェント(skywork)
kondai24
0
170
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
What's in a price? How to price your products and services
michaelherold
246
13k
Documentation Writing (for coders)
carmenintech
76
5.2k
Done Done
chrislema
186
16k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
54k
Optimizing for Happiness
mojombo
379
70k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Building Flexible Design Systems
yeseniaperezcruz
330
39k
The Language of Interfaces
destraynor
162
25k
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