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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
170
Swift Attributes
hokuron
0
460
Peek in Calendar implementation of swift-foundation
hokuron
0
240
MVVM
hokuron
0
72
Summon Rust from Swift
hokuron
0
710
Generalized accessors
hokuron
0
89
Ownership of Swift as seen from iteration and Rust
hokuron
1
730
Clean Architecture 3
hokuron
0
70
Clean Architecture 2
hokuron
0
87
Other Decks in Programming
See All in Programming
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
3
890
Programming with a DJ Controller — not vibe coding
m_seki
3
840
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
410
GoogleCloudとterraform完全に理解した
terisuke
1
200
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
460
Kingdom of the Machine
yui_knk
2
1.5k
SkillsをS3 Filesに置く時のあれこれ
watany
3
1.6k
Agentic UI in the Frontend: Architectures with Open Standards @JAX 2026 in Mainz
manfredsteyer
PRO
0
110
Terraform言語の静的解析 / static analysis of Terraform language
wata727
1
140
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
190
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
3
350
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
350
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.4k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.6k
What's in a price? How to price your products and services
michaelherold
247
13k
A better future with KSS
kneath
240
18k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
49
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Color Theory Basics | Prateek | Gurzu
gurzu
0
310
Visualization
eitanlees
150
17k
The Cult of Friendly URLs
andyhume
79
6.9k
Google's AI Overviews - The New Search
badams
0
1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
550
The untapped power of vector embeddings
frankvandijk
2
1.7k
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