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
140
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
370
Peek in Calendar implementation of swift-foundation
hokuron
0
150
MVVM
hokuron
0
43
Summon Rust from Swift
hokuron
0
630
Generalized accessors
hokuron
0
67
Ownership of Swift as seen from iteration and Rust
hokuron
1
630
Clean Architecture 3
hokuron
0
35
Clean Architecture 2
hokuron
0
54
Create MLで犬と猫の肉球を学習
hokuron
0
90
Other Decks in Programming
See All in Programming
『改訂新版 良いコード/悪いコードで学ぶ設計入門』活用方法−爆速でスキルアップする!効果的な学習アプローチ / effective-learning-of-good-code
minodriven
29
4.9k
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
240
asdf-ecspresso作って 友達が増えた話 / Fujiwara Tech Conference 2025
koluku
0
2.5k
Alba: Why, How and What's So Interesting
okuramasafumi
0
240
ASP.NET Core の OpenAPIサポート
h455h1
0
170
Azure AI Foundryのご紹介
qt_luigi
1
270
functionalなアプローチで動的要素を排除する
ryopeko
1
1.1k
最近のVS Codeで気になるニュース 2025/01
74th
1
240
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
140
自分ひとりから始められる生産性向上の取り組み #でぃーぷらすオオサカ
irof
8
2.2k
Rubyでつくるパケットキャプチャツール
ydah
1
610
ATDDで素早く安定した デリバリを実現しよう!
tonnsama
1
2.5k
Featured
See All Featured
Thoughts on Productivity
jonyablonski
69
4.4k
Documentation Writing (for coders)
carmenintech
67
4.6k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Fireside Chat
paigeccino
34
3.2k
Music & Morning Musume
bryan
46
6.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Facilitating Awesome Meetings
lara
51
6.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
Practical Orchestrator
shlominoach
186
10k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
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