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
Rustで定数式を扱う
Search
Kazumasa Yamamoto
October 27, 2020
Programming
0
430
Rustで定数式を扱う
Kazumasa Yamamoto
October 27, 2020
Tweet
Share
More Decks by Kazumasa Yamamoto
See All by Kazumasa Yamamoto
ユニークビジョンの Rust 活用事例
fill9120
2
1.6k
Rust & AWS X-Ray による分散トレーシングの実現
fill9120
0
2.8k
Rust製プロダクトを 3年以上運用して得たノウハウ
fill9120
0
960
Messaging APIを駆使した ChatGPT ボットのUX改善
fill9120
0
360
Rust を開発言語として採用してからの取り組み
fill9120
1
1.8k
ストラクチャードコミュニケーション
fill9120
0
120
Cloudflare PagesにVue.jsアプリをデプロイしてみた
fill9120
0
930
Rustでディープラーニング
fill9120
0
400
LINE BotとLIFFを使って謎解きアプリを作った話
fill9120
0
680
Other Decks in Programming
See All in Programming
Herb to ReActionView: A New Foundation for the View Layer @ San Francisco Ruby Conference 2025
marcoroth
0
180
TypeScriptで設計する 堅牢さとUXを両立した非同期ワークフローの実現
moeka__c
0
390
スタートアップを支える技術戦略と組織づくり
pospome
8
8.8k
GeistFabrik and AI-augmented software development
adewale
PRO
0
120
Rails Girls Sapporo 2ndの裏側―準備の日々から見えた、私が得たもの / SAPPORO ENGINEER BASE #11
lemonade_37
2
180
Atomics APIを知る / Understanding Atomics API
ssssota
1
160
Building AI Agents with TypeScript #TSKaigiHokuriku
izumin5210
5
820
ゼロダウンタイムでミドルウェアの バージョンアップを実現した手法と課題
wind111
0
210
開発生産性が組織文化になるまでの軌跡
tonegawa07
0
180
OSS開発者の憂鬱
yusukebe
12
5.5k
Evolving NEWT’s TypeScript Backend for the AI-Driven Era
xpromx
0
150
知られているようで知られていない JavaScriptの仕様 4選
syumai
0
630
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Code Review Best Practice
trishagee
72
19k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
980
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.2k
Bash Introduction
62gerente
615
210k
Transcript
Rustで定数式を扱う ユニークビジョン株式会社 山本 一将
自己紹介 2 ⚫ 名前:山本 一将(@kyamamoto9120) ⚫ 所属:ユニークビジョン株式会社 ⚫ 言語:C++, Rust,
Python, Ruby ⚫ 趣味:将棋、キャンプ、DIY、野球観戦 ⚫ 実績:2015年 世界コンピュータ将棋選手権9位
アジェンダ 3 ① 定数式とは何か ② Rustの定数式の状況 ③ 簡単な使用方法(フィボナッチ数列を例に)
定数式とは 4 • コンパイル時に評価可能な式のこと • Rustでは const fn で始まる関数が定数式となる
Rustにおける定数式 5 ① 1.31.0から導入 • ローカル変数が使えない • ループ文、制御文が使えない • 引数を&mutにできない
② 1.46.0までに徐々に制限緩和 • ローカル変数が使える! • matchやwhileが使える!
現時点での制限 6 ① for文は使えない ② 評価できる式の深さに制限がある
まとめ 7 ⚫ 制限が一部緩和されたがまだまだ実用レベルではない • 自由度はまだC++14のconstexprにも届かない • 標準ライブラリの対応もまだまだ ⚫ 当面はlazy_static!を使用した方が幸せ
⚫ それでも1.46.0での制限緩和は希望がある!
ありがとうございました