-
Notifications
You must be signed in to change notification settings - Fork 214
Description
I never realized until recently that BaseElement::as_int
is not actually a zero-cost operation, but actually does a non-zero-cost operation (montgomery reduction).
This is because the as_
prefix suggests that the cost of the operation is zero-cost, according to the widely used Rust naming conventions. This may seem like a small thing, but naming shapes the mental model and I was happily using as_int
everywhere because I assumed it was zero-cost.
According to that guideline, this should instead use the to_
prefix. In that case we'd have to change the signature from &self
to self
to avoid triggering clippy::wrong_self_convention
. That shouldn't affect the API, since BaseElement
is Copy
anyway.
If we rename this, I think it would be good to choose a more precise name as well and call it to_u64
, because it returns a u64
whereas int
suggests something more generic, but that's a small thing that just neatly fits into the larger issue.