Skip to content

Commit e5ae818

Browse files
committed
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)]`
1 parent d1a9802 commit e5ae818

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/slice/raw.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
213213
///
214214
/// [valid]: ptr#safety
215215
#[unstable(feature = "slice_from_ptr_range", issue = "89792")]
216-
pub unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
216+
#[rustc_const_unstable(feature = "slice_from_ptr_range_const", issue = "89792")]
217+
pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
217218
// SAFETY: the caller must uphold the safety contract for `from_ptr_range`.
218219
unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) }
219220
}
@@ -263,7 +264,8 @@ pub unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
263264
///
264265
/// [valid]: ptr#safety
265266
#[unstable(feature = "slice_from_ptr_range", issue = "89792")]
266-
pub unsafe fn from_mut_ptr_range<'a, T>(range: Range<*mut T>) -> &'a mut [T] {
267+
#[rustc_const_unstable(feature = "slice_from_mut_ptr_range_const", issue = "89792")]
268+
pub const unsafe fn from_mut_ptr_range<'a, T>(range: Range<*mut T>) -> &'a mut [T] {
267269
// SAFETY: the caller must uphold the safety contract for `from_mut_ptr_range`.
268270
unsafe { from_raw_parts_mut(range.start, range.end.sub_ptr(range.start)) }
269271
}

0 commit comments

Comments
 (0)