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
420
Rustで定数式を扱う
Kazumasa Yamamoto
October 27, 2020
Tweet
Share
More Decks by Kazumasa Yamamoto
See All by Kazumasa Yamamoto
ユニークビジョンの Rust 活用事例
fill9120
1
1.3k
Rust & AWS X-Ray による分散トレーシングの実現
fill9120
0
2.6k
Rust製プロダクトを 3年以上運用して得たノウハウ
fill9120
0
890
Messaging APIを駆使した ChatGPT ボットのUX改善
fill9120
0
350
Rust を開発言語として採用してからの取り組み
fill9120
1
1.8k
ストラクチャードコミュニケーション
fill9120
0
110
Cloudflare PagesにVue.jsアプリをデプロイしてみた
fill9120
0
820
Rustでディープラーニング
fill9120
0
380
LINE BotとLIFFを使って謎解きアプリを作った話
fill9120
0
640
Other Decks in Programming
See All in Programming
Cline指示通りに動かない? AI小説エージェントで学ぶ指示書の書き方と自動アップデートの仕組み
kamomeashizawa
1
570
ReadMoreTextView
fornewid
1
460
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.3k
5つのアンチパターンから学ぶLT設計
narihara
1
110
FormFlow - Build Stunning Multistep Forms
yceruto
1
190
関数型まつりレポート for JuliaTokai #22
antimon2
0
150
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
2
220
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
240
生成AIで日々のエラー調査を進めたい
yuyaabo
0
640
都市をデータで見るってこういうこと PLATEAU属性情報入門
nokonoko1203
1
560
datadog dash 2025 LLM observability for reliability and stability
ivry_presentationmaterials
0
110
Effect の双対、Coeffect
yukikurage
5
1.4k
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
Typedesign – Prime Four
hannesfritz
42
2.7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
790
RailsConf 2023
tenderlove
30
1.1k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Done Done
chrislema
184
16k
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での制限緩和は希望がある!
ありがとうございました