Rollup merge of #140685 - viliml:patch-1, r=Mark-Simulacrum
Simplify `Vec::as_non_null` implementation and make it `const` Tracking issue: #130364.
This commit is contained in:
commit
7a8fd9985d
2 changed files with 4 additions and 4 deletions
|
|
@ -287,7 +287,7 @@ impl<T, A: Allocator> RawVec<T, A> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn non_null(&self) -> NonNull<T> {
|
||||
pub(crate) const fn non_null(&self) -> NonNull<T> {
|
||||
self.inner.non_null()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1816,10 +1816,10 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
/// [`as_ptr`]: Vec::as_ptr
|
||||
/// [`as_non_null`]: Vec::as_non_null
|
||||
#[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")]
|
||||
#[rustc_const_unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")]
|
||||
#[inline]
|
||||
pub fn as_non_null(&mut self) -> NonNull<T> {
|
||||
// SAFETY: A `Vec` always has a non-null pointer.
|
||||
unsafe { NonNull::new_unchecked(self.as_mut_ptr()) }
|
||||
pub const fn as_non_null(&mut self) -> NonNull<T> {
|
||||
self.buf.non_null()
|
||||
}
|
||||
|
||||
/// Returns a reference to the underlying allocator.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue