最近,我想为3D投影编写一个包含参数的类型:
use std::ops::Range;
#[derive(Clone, Copy)]
struct CamProj {
/// Near and far plane
proj_range: Range<f32>,
/// Field of view
fov: cgmath::Rad<f32>, // `Rad` derives `Copy`
/// Width divided by height
aspect_ratio: f32,
}
然而,我得到了这个错误:
error[E0204]: the trait `Copy` may not be implemented for this type
--> <anon>:3:21
|
3 | #[derive(Clone, Copy)]
| ^^^^
...
6 | proj_range: Range<f32>,
| ---------------------- this field does not implement `Copy`
显然,Range<T>
永远不会实现Copy
,即使T
是Copy
,就像f32
是.Why is that?我以为Range<T>
就是T
?那么它肯定能实现Copy
?