Trait feanor_math::integer::IntCast
source · pub trait IntCast<F: ?Sized + IntegerRing>: IntegerRing {
// Required method
fn cast(&self, from: &F, value: F::Element) -> Self::Element;
}Expand description
Helper trait to simplify conversion between ints.
More concretely, IntCast defines a conversion between two
integer rings, and is default-implemented for all integer rings
using a double-and-and technique. All implementors of integer
rings are encouraged to provide specializations for improved performance.
§Why yet another conversion trait?
It is a common requirement to convert between arbitrary (i.e. generic) integer rings. To achieve this, we require a blanket implementation anyway.
Now it would be possible to just provide a blanket implementation of
CanHomFrom and specialize it for all integer rings. However, it turned
out that in all implementations, the homomorphism requires no additional
data and always exists. Hence, it seemed easier to add another, simpler
trait for the same thing.