Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- // WILL COMPILE BECAUSE VALUE IS KNOWN AT COMPILE TIME
- const MAX_POINT : i32 = 500;
- //WILL NOT COMPILE BECAUSE value can not be calculated at compile-time in stable
- //although note: a limited form of compile-time function evaluation is available
- //on a nightly compiler via `const fn`
- const CALC_MAX_POINT : i32 = calculate_max_point(32);
- }
- fn calculate_max_point(val : i32) -> i32 {
- val * 2
- }
- // Hint: The declaration on line 5 is missing a keyword that is needed in Rust
- // to create a new variable binding.
Add Comment
Please, Sign In to add comment