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
0
170
Opaque Result Type in Swift with Rust
Takuma Shimizu
March 27, 2019
Tweet
Share
More Decks by Takuma Shimizu
See All by Takuma Shimizu
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
72
Swift Attributes
hokuron
0
450
Peek in Calendar implementation of swift-foundation
hokuron
0
220
MVVM
hokuron
0
55
Summon Rust from Swift
hokuron
0
700
Generalized accessors
hokuron
0
83
Ownership of Swift as seen from iteration and Rust
hokuron
1
710
Clean Architecture 3
hokuron
0
62
Clean Architecture 2
hokuron
0
79
Other Decks in Programming
See All in Programming
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
360
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
1.1k
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
140
JPUG勉強会 OSSデータベースの内部構造を理解しよう
oga5
2
250
開発ステップを細分化する、破綻しないAI開発体制
kspace
0
110
2026年は Rust 置き換えが流行る! / 20260220-niigata-5min-tech
girigiribauer
0
220
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
150
Event Storming
hschwentner
3
1.3k
RubyとGoでゼロから作る証券システム: 高信頼性が求められるシステムのコードの外側にある設計と運用のリアル
free_world21
0
220
AI主導でFastAPIのWebサービスを作るときに 人間が構造化すべき境界線
okajun35
0
600
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
330
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
310
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
My Coaching Mixtape
mlcsv
0
64
Skip the Path - Find Your Career Trail
mkilby
1
72
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
470
Discover your Explorer Soul
emna__ayadi
2
1.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Crafting Experiences
bethany
1
79
We Are The Robots
honzajavorek
0
190
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
150
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
230
Measuring & Analyzing Core Web Vitals
bluesmoon
9
770
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