Closed ElectricCoffee closed 5 years ago
Thanks, I agree!
I'm actually pretty sure this is available under Rust 2015 as well though I don't remember when they were introduced.
I'm absolutely in favour of doing this, but I don't expect to have a lot of time doing this myself. If you (or anyone else reading this) were interested in putting together a PR, I would be thrilled to review & merge it.
I'll see what I can do :)
The #283 PR is merged. Closing.
Rust 2018 has a notion of "const functions", which are functions that can evaluate at compile-time if it makes sense to do so.
Proposal
This issue proposes changing
to
Motivation
The motivation is rather simple, really; it lets us write this:
like this:
Which (to me) is a bit ergonomic than having to use the full struct syntax.
Other similar functions could also be changed in similar ways to allow for compile-time resolution.
PS There's no reason to write
r: r, g: g, b: b
when the shorthand syntax just lets you insert variables with the same names as the fields directly. So I took the liberty to simplify that in the example