| 1 |
#![feature(intrinsics)] |
| 2 |
|
| 3 |
#[lang = "sized"] |
| 4 |
pub trait Sized {} |
| 5 |
|
| 6 |
extern "rust-intrinsic" { |
| 7 |
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")] |
| 8 |
pub fn offset<T>(dst: *const T, offset: isize) -> *const T; |
| 9 |
} |
| 10 |
|
| 11 |
#[lang = "const_ptr"] |
| 12 |
impl<T> *const T { |
| 13 |
pub const unsafe fn offset(self, count: isize) -> *const T { |
| 14 |
unsafe { offset(self, count) } |
| 15 |
} |
| 16 |
|
| 17 |
pub const unsafe fn add(self, count: usize) -> Self { |
| 18 |
unsafe { self.offset(count as isize) } |
| 19 |
} |
| 20 |
} |