Make some trivial functions #[inline(always)]
This commit is contained in:
parent
91b8f34ac2
commit
00e7b54d46
9 changed files with 33 additions and 25 deletions
|
@ -45,7 +45,7 @@ impl<T: ?Sized> *const T {
|
|||
/// Casts to a pointer of another type.
|
||||
#[stable(feature = "ptr_cast", since = "1.38.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_cast", since = "1.38.0")]
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
pub const fn cast<U>(self) -> *const U {
|
||||
self as _
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ impl<T: ?Sized> *const T {
|
|||
/// refactored.
|
||||
#[stable(feature = "ptr_const_cast", since = "1.65.0")]
|
||||
#[rustc_const_stable(feature = "ptr_const_cast", since = "1.65.0")]
|
||||
#[inline(always)]
|
||||
pub const fn cast_mut(self) -> *mut T {
|
||||
self as _
|
||||
}
|
||||
|
@ -126,6 +127,7 @@ impl<T: ?Sized> *const T {
|
|||
note = "replaced by the `exposed_addr` method, or update your code \
|
||||
to follow the strict provenance rules using its APIs"
|
||||
)]
|
||||
#[inline(always)]
|
||||
pub fn to_bits(self) -> usize
|
||||
where
|
||||
T: Sized,
|
||||
|
@ -155,6 +157,7 @@ impl<T: ?Sized> *const T {
|
|||
your code to follow the strict provenance rules using its APIs"
|
||||
)]
|
||||
#[allow(fuzzy_provenance_casts)] // this is an unstable and semi-deprecated cast function
|
||||
#[inline(always)]
|
||||
pub fn from_bits(bits: usize) -> Self
|
||||
where
|
||||
T: Sized,
|
||||
|
@ -186,7 +189,7 @@ impl<T: ?Sized> *const T {
|
|||
/// might change in the future (including possibly weakening this so it becomes wholly
|
||||
/// equivalent to `self as usize`). See the [module documentation][crate::ptr] for details.
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||
pub fn addr(self) -> usize
|
||||
where
|
||||
|
@ -223,7 +226,7 @@ impl<T: ?Sized> *const T {
|
|||
///
|
||||
/// [`from_exposed_addr`]: from_exposed_addr
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "strict_provenance", issue = "95228")]
|
||||
pub fn expose_addr(self) -> usize
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue