@@ -20,7 +20,7 @@ use std::ops::{AddAssign, SubAssign};
2020use std:: marker:: PhantomData ;
2121use std:: fmt;
2222
23- #[ derive( RustcDecodable , RustcEncodable ) ]
23+ #[ derive( Clone , Copy , RustcDecodable , RustcEncodable ) ]
2424pub struct UnknownUnit ;
2525
2626/// A one-dimensional distance, with value represented by `T` and unit of measurement `Unit`.
@@ -36,7 +36,7 @@ pub struct UnknownUnit;
3636/// another. See the `ScaleFactor` docs for an example.
3737// Uncomment the derive, and remove the macro call, once heapsize gets
3838// PhantomData<T> support.
39- #[ derive( RustcDecodable , RustcEncodable ) ]
39+ #[ derive( Clone , Copy , RustcDecodable , RustcEncodable ) ]
4040pub struct Length < T , Unit > ( pub T , PhantomData < Unit > ) ;
4141
4242impl < Unit , T : HeapSizeOf > HeapSizeOf for Length < T , Unit > {
@@ -64,8 +64,6 @@ impl<T, Unit> Length<T, Unit> {
6464 }
6565}
6666
67- impl < T : Copy , Unit > Copy for Length < T , Unit > { }
68-
6967impl < Unit , T : Clone > Length < T , Unit > {
7068 pub fn get ( & self ) -> T {
7169 self . 0 . clone ( )
@@ -157,15 +155,6 @@ impl<Unit, T0: NumCast + Clone> Length<T0, Unit> {
157155 }
158156}
159157
160- // FIXME: Switch to `derive(Clone, PartialEq, PartialOrd, Zero)` after this Rust issue is fixed:
161- // https://github.com/mozilla/rust/issues/7671
162-
163- impl < Unit , T : Clone > Clone for Length < T , Unit > {
164- fn clone ( & self ) -> Length < T , Unit > {
165- Length :: new ( self . get ( ) )
166- }
167- }
168-
169158impl < Unit , T : Clone + PartialEq > PartialEq for Length < T , Unit > {
170159 fn eq ( & self , other : & Length < T , Unit > ) -> bool { self . get ( ) . eq ( & other. get ( ) ) }
171160}
0 commit comments