Skip to content

Commit d31fbe3

Browse files
committed
core: implement TrivialClone for arrays and Option
1 parent 80e881f commit d31fbe3

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

library/core/src/array/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ impl<T: Clone, const N: usize> Clone for [T; N] {
427427
}
428428
}
429429

430+
#[unstable(feature = "trivial_clone", issue = "none")]
431+
unsafe impl<T: TrivialClone, const N: usize> TrivialClone for [T; N] {}
432+
430433
trait SpecArrayClone: Clone {
431434
fn clone<const N: usize>(array: &[Self; N]) -> [Self; N];
432435
}

library/core/src/option.rs

+4
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@
556556
557557
#![stable(feature = "rust1", since = "1.0.0")]
558558

559+
use crate::clone::TrivialClone;
559560
use crate::iter::{self, FusedIterator, TrustedLen};
560561
use crate::ops::{self, ControlFlow, Deref, DerefMut};
561562
use crate::panicking::{panic, panic_display};
@@ -2050,6 +2051,9 @@ where
20502051
}
20512052
}
20522053

2054+
#[unstable(feature = "trivial_clone", issue = "none")]
2055+
unsafe impl<T: TrivialClone> TrivialClone for Option<T> {}
2056+
20532057
#[stable(feature = "rust1", since = "1.0.0")]
20542058
impl<T> Default for Option<T> {
20552059
/// Returns [`None`][Option::None].

0 commit comments

Comments
 (0)