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
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
Swift Attributes
hokuron
0
450
Peek in Calendar implementation of swift-foundation
hokuron
0
210
MVVM
hokuron
0
52
Summon Rust from Swift
hokuron
0
690
Generalized accessors
hokuron
0
82
Ownership of Swift as seen from iteration and Rust
hokuron
1
700
Clean Architecture 3
hokuron
0
59
Clean Architecture 2
hokuron
0
77
Create MLで犬と猫の肉球を学習
hokuron
0
100
Other Decks in Programming
See All in Programming
公共交通オープンデータ × モバイルUX 複雑な運行情報を 『直感』に変換する技術
tinykitten
PRO
0
170
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
140
gunshi
kazupon
1
130
LLM Çağında Backend Olmak: 10 Milyon Prompt'u Milisaniyede Sorgulamak
selcukusta
0
140
AIエージェントの設計で注意するべきポイント6選
har1101
6
2.7k
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
5
1.5k
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
150
perlをWebAssembly上で動かすと何が嬉しいの??? / Where does Perl-on-Wasm actually make sense?
mackee
0
240
ゆくKotlin くるRust
exoego
1
180
JETLS.jl ─ A New Language Server for Julia
abap34
2
470
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
540
Go コードベースの構成と AI コンテキスト定義
andpad
0
150
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
680
WCS-LA-2024
lcolladotor
0
390
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.9k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
0
26
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
1
37
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
74
The Mindset for Success: Future Career Progression
greggifford
PRO
0
200
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
170
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
78
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
54
Embracing the Ebb and Flow
colly
88
4.9k
Building Applications with DynamoDB
mza
96
6.9k
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