Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Taking Constant Evaluation to the Limit - RustConf 2019

Rust via YouTube

Overview

Explore the intricacies of constant evaluation in Rust with this RustConf 2019 talk by Oliver Schneider. Delve into the new theoretically unrestricted constant evaluator in rustc, nicknamed Miri (MIR interpreter), and discover its potential for complex static initializations, microcontroller programming, and runtime code reduction. Learn about the grading of constant evaluators, necessary and unnecessary restrictions, and the challenges of heap allocations. Examine practical examples, including String implementations and unsafe operations in constants, while understanding the stricter rules applied at compile-time. Gain insights into compile-time undefined behavior, const assertions on stable Rust, and even witness a Fibonacci sequence calculated at compile-time. Perfect for Rust developers seeking to push the boundaries of constant evaluation and optimize their code.

Syllabus

Intro
Why const eval?
Grading constant evaluators
Why restrict ourselves?
What restrictions do we want?
What unnecessary restrictions do we have?
Open RFC
Details, details, details ...
Heap allocations...
Heap problems
Example with String
impl Send for &Sync
Unsafe in constants
compile time undefined behavior
Not UB
Much stricter rules at compile-time
Less stricter rules at compile-time
Summary
Don't try this at home
Const assertions on stable rust
Fibonacci at compile-time
Spot the fib

Taught by

Rust

Reviews

Start your review of Taking Constant Evaluation to the Limit - RustConf 2019

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.