Skip to content

Commit 62cf244

Browse files
committed
Constify copy_to and copy_from
1 parent 2ccf063 commit 62cf244

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

library/core/src/ptr/const_ptr.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,10 @@ impl<T: ?Sized> *const T {
819819
/// See [`ptr::copy`] for safety concerns and examples.
820820
///
821821
/// [`ptr::copy`]: crate::ptr::copy()
822+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
822823
#[stable(feature = "pointer_methods", since = "1.26.0")]
823824
#[inline]
824-
pub unsafe fn copy_to(self, dest: *mut T, count: usize)
825+
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
825826
where
826827
T: Sized,
827828
{
@@ -837,9 +838,10 @@ impl<T: ?Sized> *const T {
837838
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
838839
///
839840
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
841+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
840842
#[stable(feature = "pointer_methods", since = "1.26.0")]
841843
#[inline]
842-
pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
844+
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
843845
where
844846
T: Sized,
845847
{

library/core/src/ptr/mut_ptr.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,10 @@ impl<T: ?Sized> *mut T {
926926
/// See [`ptr::copy`] for safety concerns and examples.
927927
///
928928
/// [`ptr::copy`]: crate::ptr::copy()
929+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
929930
#[stable(feature = "pointer_methods", since = "1.26.0")]
930931
#[inline]
931-
pub unsafe fn copy_to(self, dest: *mut T, count: usize)
932+
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
932933
where
933934
T: Sized,
934935
{
@@ -944,9 +945,10 @@ impl<T: ?Sized> *mut T {
944945
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
945946
///
946947
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
948+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
947949
#[stable(feature = "pointer_methods", since = "1.26.0")]
948950
#[inline]
949-
pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
951+
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
950952
where
951953
T: Sized,
952954
{
@@ -962,9 +964,10 @@ impl<T: ?Sized> *mut T {
962964
/// See [`ptr::copy`] for safety concerns and examples.
963965
///
964966
/// [`ptr::copy`]: crate::ptr::copy()
967+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
965968
#[stable(feature = "pointer_methods", since = "1.26.0")]
966969
#[inline]
967-
pub unsafe fn copy_from(self, src: *const T, count: usize)
970+
pub const unsafe fn copy_from(self, src: *const T, count: usize)
968971
where
969972
T: Sized,
970973
{
@@ -980,9 +983,10 @@ impl<T: ?Sized> *mut T {
980983
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
981984
///
982985
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
986+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
983987
#[stable(feature = "pointer_methods", since = "1.26.0")]
984988
#[inline]
985-
pub unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
989+
pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
986990
where
987991
T: Sized,
988992
{

0 commit comments

Comments
 (0)