@@ -21,8 +21,6 @@ the `clone` method.
21
21
22
22
*/
23
23
24
- use std:: kinds:: Freeze ;
25
-
26
24
/// A common trait for cloning an object.
27
25
pub trait Clone {
28
26
/// Returns a copy of the value. The contents of owned pointers
@@ -125,92 +123,6 @@ extern_fn_clone!(A, B, C, D, E, F)
125
123
extern_fn_clone ! ( A , B , C , D , E , F , G )
126
124
extern_fn_clone ! ( A , B , C , D , E , F , G , H )
127
125
128
- /// A trait distinct from `Clone` which represents "deep copies" of things like
129
- /// managed boxes which would otherwise not be copied.
130
- pub trait DeepClone : Clone {
131
- /// Return a deep copy of the value. Unlike `Clone`, the contents of shared pointer types
132
- /// *are* copied.
133
- fn deep_clone ( & self ) -> Self ;
134
-
135
- /// Perform deep copy-assignment from `source`.
136
- ///
137
- /// `a.deep_clone_from(&b)` is equivalent to `a = b.deep_clone()` in
138
- /// functionality, but can be overridden to reuse the resources of `a` to
139
- /// avoid unnecessary allocations.
140
- #[ inline( always) ]
141
- fn deep_clone_from ( & mut self , source : & Self ) {
142
- * self = source. deep_clone ( )
143
- }
144
- }
145
-
146
- impl < T : DeepClone > DeepClone for ~T {
147
- /// Return a deep copy of the owned box.
148
- #[ inline]
149
- fn deep_clone ( & self ) -> ~T { ~( * * self ) . deep_clone ( ) }
150
-
151
- /// Perform deep copy-assignment from `source` by reusing the existing allocation.
152
- fn deep_clone_from ( & mut self , source : & ~T ) {
153
- * * self = ( * * source) . deep_clone ( )
154
- }
155
- }
156
-
157
- // FIXME: #6525: should also be implemented for `T: Send + DeepClone`
158
- impl < T : Freeze + DeepClone + ' static > DeepClone for @T {
159
- /// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
160
- /// a deep clone of a potentially cyclical type.
161
- #[ inline]
162
- fn deep_clone ( & self ) -> @T { @( * * self ) . deep_clone ( ) }
163
- }
164
-
165
- macro_rules! deep_clone_impl(
166
- ( $t: ty) => {
167
- impl DeepClone for $t {
168
- /// Return a deep copy of the value.
169
- #[ inline]
170
- fn deep_clone( & self ) -> $t { * self }
171
- }
172
- }
173
- )
174
-
175
- deep_clone_impl ! ( int)
176
- deep_clone_impl ! ( i8 )
177
- deep_clone_impl ! ( i16 )
178
- deep_clone_impl ! ( i32 )
179
- deep_clone_impl ! ( i64 )
180
-
181
- deep_clone_impl ! ( uint)
182
- deep_clone_impl ! ( u8 )
183
- deep_clone_impl ! ( u16 )
184
- deep_clone_impl ! ( u32 )
185
- deep_clone_impl ! ( u64 )
186
-
187
- deep_clone_impl ! ( f32 )
188
- deep_clone_impl ! ( f64 )
189
-
190
- deep_clone_impl ! ( ( ) )
191
- deep_clone_impl ! ( bool )
192
- deep_clone_impl ! ( char )
193
-
194
- macro_rules! extern_fn_deep_clone(
195
- ( $( $A: ident) ,* ) => (
196
- impl <$( $A, ) * ReturnType > DeepClone for extern "Rust" fn ( $( $A) ,* ) -> ReturnType {
197
- /// Return a copy of a function pointer
198
- #[ inline]
199
- fn deep_clone( & self ) -> extern "Rust" fn ( $( $A) ,* ) -> ReturnType { * self }
200
- }
201
- )
202
- )
203
-
204
- extern_fn_deep_clone ! ( )
205
- extern_fn_deep_clone ! ( A )
206
- extern_fn_deep_clone ! ( A , B )
207
- extern_fn_deep_clone ! ( A , B , C )
208
- extern_fn_deep_clone ! ( A , B , C , D )
209
- extern_fn_deep_clone ! ( A , B , C , D , E )
210
- extern_fn_deep_clone ! ( A , B , C , D , E , F )
211
- extern_fn_deep_clone ! ( A , B , C , D , E , F , G )
212
- extern_fn_deep_clone ! ( A , B , C , D , E , F , G , H )
213
-
214
126
#[ test]
215
127
fn test_owned_clone ( ) {
216
128
let a = ~5 i;
@@ -241,14 +153,6 @@ fn test_clone_from() {
241
153
assert_eq ! ( * b, 5 ) ;
242
154
}
243
155
244
- #[ test]
245
- fn test_deep_clone_from ( ) {
246
- let a = ~5 ;
247
- let mut b = ~10 ;
248
- b. deep_clone_from ( & a) ;
249
- assert_eq ! ( * b, 5 ) ;
250
- }
251
-
252
156
#[ test]
253
157
fn test_extern_fn_clone ( ) {
254
158
trait Empty { }
@@ -261,8 +165,4 @@ fn test_extern_fn_clone() {
261
165
let _ = test_fn_a. clone ( ) ;
262
166
let _ = test_fn_b :: < int > . clone ( ) ;
263
167
let _ = test_fn_c. clone ( ) ;
264
-
265
- let _ = test_fn_a. deep_clone ( ) ;
266
- let _ = test_fn_b :: < int > . deep_clone ( ) ;
267
- let _ = test_fn_c. deep_clone ( ) ;
268
168
}
0 commit comments