mirror of
https://github.com/openharmony/third_party_rust_memoffset.git
synced 2026-07-19 14:33:32 -04:00
explain let_base_ptr
This commit is contained in:
@@ -26,6 +26,10 @@
|
||||
macro_rules! let_base_ptr {
|
||||
($name:ident, $type:tt) => {
|
||||
// No UB here, and the pointer does not dangle, either.
|
||||
// But we have to make sure that `uninit` lives long enough,
|
||||
// so it has to be in the same scope as `$name`. That's why
|
||||
// `let_base_ptr` declares a variable (several, actually)
|
||||
// instad of returning one.
|
||||
let uninit = $crate::mem::MaybeUninit::<$type>::uninit();
|
||||
let $name = uninit.as_ptr();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user