Make from{,_mut}_ptr_range
const
- `from_ptr_range` uses `#![feature(slice_from_ptr_range_const)]` - `from_mut_ptr_range` uses `#![feature(slice_from_mut_ptr_range_const)]`
This commit is contained in:
parent
855fc022fe
commit
19caa8c89b
@ -213,7 +213,8 @@ pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
|
||||
///
|
||||
/// [valid]: ptr#safety
|
||||
#[unstable(feature = "slice_from_ptr_range", issue = "89792")]
|
||||
pub unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
|
||||
#[rustc_const_unstable(feature = "slice_from_ptr_range_const", issue = "89792")]
|
||||
pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
|
||||
// SAFETY: the caller must uphold the safety contract for `from_ptr_range`.
|
||||
unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
|
||||
}
|
||||
@ -263,7 +264,8 @@ pub unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
|
||||
///
|
||||
/// [valid]: ptr#safety
|
||||
#[unstable(feature = "slice_from_ptr_range", issue = "89792")]
|
||||
pub unsafe fn from_mut_ptr_range<'a, T>(range: Range<*mut T>) -> &'a mut [T] {
|
||||
#[rustc_const_unstable(feature = "slice_from_mut_ptr_range_const", issue = "89792")]
|
||||
pub const unsafe fn from_mut_ptr_range<'a, T>(range: Range<*mut T>) -> &'a mut [T] {
|
||||
// SAFETY: the caller must uphold the safety contract for `from_mut_ptr_range`.
|
||||
unsafe { from_raw_parts_mut(range.start, range.end.sub_ptr(range.start)) }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user