expression
Rust Inline const blocks
An inline const block requests compile-time evaluation of its body. Use it for a small value that must be computable at compile time. Expected output (not executed): 4096 Why: The multiplication is suitable for constant evaluation. Common mistake: Do not try to read a runtime local variable in an inline const block.
Formal Syntax & Structure
rust syntaxrust
const { constant_expression }Working Example
Example Snippetrust
fn main() { let bytes = const { 4 * 1024 }; println!("{bytes}");}