dnsl48 / fraction

[Rust] Lossless fractions and decimals; drop-in float replacement
Apache License 2.0
83 stars 25 forks source link

How should I handle consts? #95

Closed DrAlta closed 2 months ago

DrAlta commented 1 year ago

Hi, I'm adding trigonometric functions as I need them for my project. Since try_into() isn't allowed in consts and I can't think of any other way to do different values for them My current approach is to have a Consts trait with an impl for GeneralFraction, GeneralFraction, GeneralFraction and so on then I made a Trigametric trait which requires the Consts trait.

I currently just have atan() and atan2() you can view my work in the trigonometrics branch of my fork

dnsl48 commented 1 year ago

Hi @DrAlta. Yes, that makes sense. That is not something we could have unified for all derived types. E.g. BigFraction, which has infinite precision, can't possibly have a meaningful implementation for Consts trait. I would also try choosing a more self-descriptive name for the Consts trait, which could imply the flavour of the consts it contains.