【发布时间】:2018-06-08 20:22:13
【问题描述】:
常规浮点文字不起作用:
extern crate num_traits;
use num_traits::float::Float;
fn scale_float<T: Float>(x: T) -> T {
x * 0.54
}
fn main() {
let a: f64 = scale_float(1.23);
}
error[E0308]: mismatched types
--> src/main.rs:6:9
|
6 | x * 0.54
| ^^^^ expected type parameter, found floating-point variable
|
= note: expected type `T`
found type `{float}`
【问题讨论】:
标签: floating-point rust traits literals