Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
730
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
97
Other Decks in Programming
See All in Programming
自分的「カンファレンスの楽しみ方」
syumai
0
200
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
100
Webの地図
yosuke_furukawa
PRO
6
3.9k
Laravelのアプリケーションをどこにデプロイするか #ツナギメオフライン.9
akase244
0
120
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
150
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
110
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
130
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
280
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
55
37k
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
120
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
1.1k
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
7
3.5k
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
A better future with KSS
kneath
240
18k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
420
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
500
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
A designer walks into a library…
pauljervisheath
211
25k
Paper Plane (Part 1)
katiecoart
PRO
1
11k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
600
[SF Ruby Conf 2025] Rails X
palkan
2
1.4k
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