@@ -91,7 +91,8 @@ pub trait Sync for Sized? {
91
91
/// implemented using unsafe code. In that case, you may want to embed
92
92
/// some of the marker types below into your type.
93
93
pub mod marker {
94
- use super :: Copy ;
94
+ use super :: { Copy , Sized } ;
95
+ use clone:: Clone ;
95
96
96
97
/// A marker type whose type parameter `T` is considered to be
97
98
/// covariant with respect to the type itself. This is (typically)
@@ -131,10 +132,13 @@ pub mod marker {
131
132
/// (for example, `S<&'static int>` is a subtype of `S<&'a int>`
132
133
/// for some lifetime `'a`, but not the other way around).
133
134
#[ lang="covariant_type" ]
134
- #[ deriving( Clone , PartialEq , Eq , PartialOrd , Ord ) ]
135
- pub struct CovariantType < T > ;
135
+ #[ deriving( PartialEq , Eq , PartialOrd , Ord ) ]
136
+ pub struct CovariantType < Sized ? T > ;
136
137
137
- impl < T > Copy for CovariantType < T > { }
138
+ impl < Sized ? T > Copy for CovariantType < T > { }
139
+ impl < Sized ? T > Clone for CovariantType < T > {
140
+ fn clone ( & self ) -> CovariantType < T > { * self }
141
+ }
138
142
139
143
/// A marker type whose type parameter `T` is considered to be
140
144
/// contravariant with respect to the type itself. This is (typically)
@@ -176,10 +180,13 @@ pub mod marker {
176
180
/// function requires arguments of type `T`, it must also accept
177
181
/// arguments of type `U`, hence such a conversion is safe.
178
182
#[ lang="contravariant_type" ]
179
- #[ deriving( Clone , PartialEq , Eq , PartialOrd , Ord ) ]
180
- pub struct ContravariantType < T > ;
183
+ #[ deriving( PartialEq , Eq , PartialOrd , Ord ) ]
184
+ pub struct ContravariantType < Sized ? T > ;
181
185
182
- impl < T > Copy for ContravariantType < T > { }
186
+ impl < Sized ? T > Copy for ContravariantType < T > { }
187
+ impl < Sized ? T > Clone for ContravariantType < T > {
188
+ fn clone ( & self ) -> ContravariantType < T > { * self }
189
+ }
183
190
184
191
/// A marker type whose type parameter `T` is considered to be
185
192
/// invariant with respect to the type itself. This is (typically)
@@ -203,10 +210,13 @@ pub mod marker {
203
210
/// never written, but in fact `Cell` uses unsafe code to achieve
204
211
/// interior mutability.
205
212
#[ lang="invariant_type" ]
206
- #[ deriving( Clone , PartialEq , Eq , PartialOrd , Ord ) ]
207
- pub struct InvariantType < T > ;
213
+ #[ deriving( PartialEq , Eq , PartialOrd , Ord ) ]
214
+ pub struct InvariantType < Sized ? T > ;
208
215
209
- impl < T > Copy for InvariantType < T > { }
216
+ impl < Sized ? T > Copy for InvariantType < T > { }
217
+ impl < Sized ? T > Clone for InvariantType < T > {
218
+ fn clone ( & self ) -> InvariantType < T > { * self }
219
+ }
210
220
211
221
/// As `CovariantType`, but for lifetime parameters. Using
212
222
/// `CovariantLifetime<'a>` indicates that it is ok to substitute
0 commit comments