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
200
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
480
Peek in Calendar implementation of swift-foundation
hokuron
0
270
MVVM
hokuron
0
86
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
99
Other Decks in Programming
See All in Programming
AHC070解法紹介
eijirou
0
150
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
140
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
6k
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
570
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.4k
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
470
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
290
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.1k
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
140
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
150
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
320
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
33
14k
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
15k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Producing Creativity
orderedlist
PRO
348
41k
The Curious Case for Waylosing
cassininazir
1
550
YesSQL, Process and Tooling at Scale
rocio
174
15k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
420
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
520
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
The SEO identity crisis: Don't let AI make you average
varn
0
570
Site-Speed That Sticks
csswizardry
13
1.5k
Documentation Writing (for coders)
carmenintech
77
5.6k
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