-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Description
use ::std::ops::Mul;
fn multiply_two_floats<C>()
where f64: Mul<C>,
{
let _ = 1.0_f64 * 1.0_f64;
}
Compiling playground v0.0.1 (file:///playground)
error[E0308]: mismatched types
--> src/main.rs:7:23
|
7 | let _ = 1.0_f64 * 1.0_f64;
| ^^^^^^^ expected type parameter, found f64
|
= note: expected type `C`
found type `f64`
I've been playing around with this since yesterday and it looks and feels like the sort of thing that would usually be a known limitation (if that makes sense)... except that I cannot seem to locate any existing discussion on it. Here's some more properties of it:
Adding f64: Mul<f64> + Mul<C>
does not resolve the issue.
It is unrelated to operators. (if you swap out Add
for some other trait and use a.method(b)
, the issue persists)
UFCS still works:
use ::std::ops::Mul;
fn multiply_two_floats<C>()
where f64: Mul<C>,
{
<f64 as Mul<f64>>::mul(1.0_f64, 1.0_f64); // ok
}
Metadata
Metadata
Assignees
Labels
No labels