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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Takuma Shimizu
March 27, 2019
Programming
180
0
Share
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
160
Swift Attributes
hokuron
0
460
Peek in Calendar implementation of swift-foundation
hokuron
0
240
MVVM
hokuron
0
66
Summon Rust from Swift
hokuron
0
710
Generalized accessors
hokuron
0
88
Ownership of Swift as seen from iteration and Rust
hokuron
1
720
Clean Architecture 3
hokuron
0
69
Clean Architecture 2
hokuron
0
86
Other Decks in Programming
See All in Programming
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
380
Angular Signal Forms
debug_mode
0
110
Back to the roots of date
jinroq
0
240
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
560
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
440
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
260
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
190
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
430
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
340
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
🦞OpenClaw works with AWS
licux
1
130
Featured
See All Featured
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.3k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
420
A Soul's Torment
seathinner
6
2.7k
The Curse of the Amulet
leimatthew05
1
11k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
350
ラッコキーワード サービス紹介資料
rakko
1
3.1M
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
190
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
320
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
What's in a price? How to price your products and services
michaelherold
247
13k
Designing for Performance
lara
611
70k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.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