Trait Scalar
pub trait Scalar:
Real<Passive = f64>
+ LiftParams
+ Copy { }Expand description
The bound every pricing body in this crate is written against.
Real alone is not enough. Its Passive associated type is not pinned, so
generic code cannot hand a &[f64] of contract data to Real::weighted_sum,
whose weights are &[Self::Passive] — the compiler has no reason to believe
the two are the same type. Every mode this crate prices in wraps f64, so
pinning it here says that once instead of at every signature, and carries the
lift along with it.
Copy is part of the bound so a generic body can use an operand twice
without cloning it. Every mode that can implement Real today is Copy;
the heap-storage mode that would not be is held out of Real upstream,
so this excludes nothing until the backend itself admits such a mode —
at which point this one line is the place to revisit.
The blanket implementation means a mode becomes a Scalar by implementing
LiftParams; there is nothing else to write.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".