Rollup merge of #129091 - RalfJung:box_as_ptr, r=Amanieu
add Box::as_ptr and Box::as_mut_ptr methods Unstably implements https://github.com/rust-lang/libs-team/issues/355. Tracking issue: https://github.com/rust-lang/rust/issues/129090. r? libs-api
This commit is contained in:
commit
7edbd6353b
4 changed files with 93 additions and 6 deletions
|
@ -34,6 +34,7 @@
|
|||
#![feature(allocator_api)]
|
||||
#![feature(array_windows)]
|
||||
#![feature(assert_matches)]
|
||||
#![feature(box_as_ptr)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(closure_track_caller)]
|
||||
#![feature(const_option)]
|
||||
|
|
|
@ -62,13 +62,11 @@ impl AllocBytes for Box<[u8]> {
|
|||
}
|
||||
|
||||
fn as_mut_ptr(&mut self) -> *mut u8 {
|
||||
// Carefully avoiding any intermediate references.
|
||||
ptr::addr_of_mut!(**self).cast()
|
||||
Box::as_mut_ptr(self).cast()
|
||||
}
|
||||
|
||||
fn as_ptr(&self) -> *const u8 {
|
||||
// Carefully avoiding any intermediate references.
|
||||
ptr::addr_of!(**self).cast()
|
||||
Box::as_ptr(self).cast()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue