Open jkelleyrtp opened 2 years ago
Does your use case require const? If you need pre-defined global variables, static variables are sufficient. For example, using once_cell, you can define immutable global variables in the current polynomial as follows.
use once_cell::sync::Lazy;
use polynomial::Polynomial;
static POLYNOMIAL: Lazy<Polynomial<i32>> = Lazy::new(|| {
Polynomial::new(vec![1, 2, 3])
});
fn main() {
println!("{}", POLYNOMIAL.pretty("x"));
}
Right now polynomial requires a Vec. It would be useful to have either a smallvec or a fixed array to avoid heap allocations.
This would let me write a library that exports polynomials as constants. IE the first complete elliptic integral for use in high-performance simulations.
Any of
[T; N]
or&'static T
would be useful.