3 ms·
Rust is planning to add that eventually, but in the meantime: fn foo(n: i32) -> i32 { n * 2 } const y: i32 = foo(3); error: function calls
by Symmetry 12y ago
Rust is planning to add that eventually, but in the meantime:
fn foo(n: i32) -> i32 {
n * 2
}
const y: i32 = foo(3);
error: function calls in constants are limited to struct and enum constructors [E0015]
- pcwalton 12y agoYou can do it with a compiler plugin; I suspect that's what the parent comment was referring to. Admittedly compiler plugins are pretty experimental at this time.
- CyberShadow 12y agoSorry about that. I haven't tried this myself, I was told by a Rust user that its CTFE was on par with D's. I guess he was mistaken.
- Jweb_Guru 12y agoNot even close, sadly.