File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,24 @@ impl<T: Ord, const N: usize> Ord for [T; N] {
330
330
}
331
331
}
332
332
333
+ #[ cfg( not( bootstrap) ) ]
334
+ #[ stable( feature = "copy_clone_array_lib" , since = "1.55.0" ) ]
335
+ impl < T : Copy , const N : usize > Copy for [ T ; N ] { }
336
+
337
+ #[ cfg( not( bootstrap) ) ]
338
+ #[ stable( feature = "copy_clone_array_lib" , since = "1.55.0" ) ]
339
+ impl < T : Clone , const N : usize > Clone for [ T ; N ] {
340
+ fn clone ( & self ) -> Self {
341
+ // SAFETY: we know for certain that this iterator will yield exactly `N`
342
+ // items.
343
+ unsafe { collect_into_array_unchecked ( & mut self . iter ( ) . cloned ( ) ) }
344
+ }
345
+
346
+ fn clone_from ( & mut self , other : & Self ) {
347
+ self . clone_from_slice ( other) ;
348
+ }
349
+ }
350
+
333
351
// The Default impls cannot be done with const generics because `[T; 0]` doesn't
334
352
// require Default to be implemented, and having different impl blocks for
335
353
// different numbers isn't supported yet.
You can’t perform that action at this time.
0 commit comments