fn my_convert<T: simba::scalar::RealField>(value: f64) -> T {
T::from_subset(&value)
}
However, the following function does not compile (replacing f64 with f32):
fn my_convert<T: simba::scalar::RealField>(value: f32) -> T {
T::from_subset(&value)
}
The non-compiling function results in error[E0308]: mismatched types with expected `&f64`, found `&f32` as the error message.
When looking for a root cause, I noticed that complex.rs's trait definition for ComplexField has SupersetOf<f64> as one of its trait bounds but not SupersetOf<f32>. If I modify this code myself, I am able to get the f32 version of my_convert to work.
I was able to reproduce this issue in the master branch as of 2024-02-24 (commit 9d95d6df788386d602b058938068a16ca866a0f1)
The following function compiles:
However, the following function does not compile (replacing
f64
withf32
):The non-compiling function results in
error[E0308]: mismatched types
withexpected `&f64`, found `&f32`
as the error message.When looking for a root cause, I noticed that
complex.rs
's trait definition forComplexField
hasSupersetOf<f64>
as one of its trait bounds but notSupersetOf<f32>
. If I modify this code myself, I am able to get thef32
version ofmy_convert
to work.I was able to reproduce this issue in the
master
branch as of 2024-02-24 (commit 9d95d6df788386d602b058938068a16ca866a0f1)