add heap_move_ok and heap_move_some helpers
This commit is contained in:
parent
0eedbf4a7f
commit
84adf166a9
9 changed files with 55 additions and 89 deletions
|
|
@ -60,6 +60,14 @@ pub(crate) fn heap_move_nonnull<T>(x: T) -> NonNull<T> {
|
|||
NonNull::from(Box::leak(Box::new(x)))
|
||||
}
|
||||
|
||||
pub(crate) fn heap_move_ok<T, E>(x: Result<T, E>) -> *mut T {
|
||||
x.map(|x| heap_move(x)).unwrap_or(std::ptr::null_mut())
|
||||
}
|
||||
|
||||
pub(crate) fn heap_move_some<T>(x: Option<T>) -> *mut T {
|
||||
x.map(|x| heap_move(x)).unwrap_or(std::ptr::null_mut())
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn heap_drop<T>(x: NonNull<T>) {
|
||||
drop(unsafe { heap_remove(x) });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue