Easier integration with rust_decimal OR fallible functions
Hello, thanks for the library. It works amazing. Perhaps my only source of pain is the combination of the following two facts:
- there is no integration with rust_decimal::Decimal; so i am forced to use conversion functions e.g.
Decimal::to_f64() - however, conversion functions are fallible and return
Option<f64>;
Besides the clutter, my concern is that i'm usually forced to unwrap() (risking panic) or unwrap_or(meaningless) when instead I'd rather have a version of the root finding functions which accept a fallible evaluation function where None signals "user error, stop iterating".
Do you think it'd be possible to support such a use case?
Is must be as simple as implementing trait FloatType for rust_decimal::Decimal, so that no conversion is needed at all. The only concern is the precision of math operations in that type.
i.e.
impl FloatType for rust_decimal::Decimal {
#[inline]
fn zero() -> Self {
simple
}
#[inline]
fn one_third() -> Self {
Precision???
}
#[inline]
fn one() -> Self {
simple
}
#[inline]
fn two_third_pi() -> Self {
Precision???
}
#[inline]
fn pi() -> Self {
Precision???
}
fn sqrt(self) -> Self {
Precision???
}
fn atan(self) -> Self {
Precision???
}
fn acos(self) -> Self {
Precision???
}
fn sin(self) -> Self {
Precision???
}
fn cos(self) -> Self {
Precision???
}
fn abs(self) -> Self {
simple
}
fn powf(self, n: Self) -> Self {
Precision???
}
}
Thumbs up on this. Would be really useful.