Constify copy_to and copy_from

This commit is contained in:
Albin Hedman 2021-03-13 19:45:48 +01:00
parent 2ccf06302c
commit 62cf244563
No known key found for this signature in database
GPG key ID: 1F501ECD1BBD70A7
2 changed files with 12 additions and 6 deletions

View file

@ -819,9 +819,10 @@ impl<T: ?Sized> *const T {
/// See [`ptr::copy`] for safety concerns and examples.
///
/// [`ptr::copy`]: crate::ptr::copy()
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline]
pub unsafe fn copy_to(self, dest: *mut T, count: usize)
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
where
T: Sized,
{
@ -837,9 +838,10 @@ impl<T: ?Sized> *const T {
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
///
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline]
pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
where
T: Sized,
{

View file

@ -926,9 +926,10 @@ impl<T: ?Sized> *mut T {
/// See [`ptr::copy`] for safety concerns and examples.
///
/// [`ptr::copy`]: crate::ptr::copy()
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline]
pub unsafe fn copy_to(self, dest: *mut T, count: usize)
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
where
T: Sized,
{
@ -944,9 +945,10 @@ impl<T: ?Sized> *mut T {
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
///
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline]
pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
where
T: Sized,
{
@ -962,9 +964,10 @@ impl<T: ?Sized> *mut T {
/// See [`ptr::copy`] for safety concerns and examples.
///
/// [`ptr::copy`]: crate::ptr::copy()
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline]
pub unsafe fn copy_from(self, src: *const T, count: usize)
pub const unsafe fn copy_from(self, src: *const T, count: usize)
where
T: Sized,
{
@ -980,9 +983,10 @@ impl<T: ?Sized> *mut T {
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
///
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
#[stable(feature = "pointer_methods", since = "1.26.0")]
#[inline]
pub unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
where
T: Sized,
{