@@ -24,6 +24,7 @@ use std::boxed::Box;
24
24
#[ cfg( all( feature = "std" , feature = "c-types" ) ) ]
25
25
pub mod c;
26
26
27
+ #[ cfg( any( feature = "panic-if-null" , debug_assertions) ) ]
27
28
#[ inline]
28
29
fn panic_if_null < T > ( pointer : * const T ) {
29
30
if pointer. is_null ( ) {
@@ -69,6 +70,7 @@ pub unsafe fn free<T>(pointer: *mut T) {
69
70
#[ cfg( any( feature = "alloc" , feature = "std" ) ) ]
70
71
#[ inline]
71
72
pub unsafe fn own_back < T > ( pointer : * mut T ) -> T {
73
+ #[ cfg( any( feature = "panic-if-null" , debug_assertions) ) ]
72
74
panic_if_null ( pointer) ;
73
75
// CAUTION: this is unsafe
74
76
let boxed = Box :: from_raw ( pointer) ;
@@ -87,6 +89,7 @@ pub unsafe fn own_back<T>(pointer: *mut T) -> T {
87
89
/// That could produce a HEAP error that produce a crash.
88
90
#[ inline]
89
91
pub unsafe fn object < ' a , T > ( pointer : * const T ) -> & ' a T {
92
+ #[ cfg( any( feature = "panic-if-null" , debug_assertions) ) ]
90
93
panic_if_null ( pointer) ;
91
94
// CAUTION: this is unsafe
92
95
return & * pointer;
@@ -104,6 +107,7 @@ pub unsafe fn object<'a, T>(pointer: *const T) -> &'a T {
104
107
/// That could produce a HEAP error that produce a crash.
105
108
#[ inline]
106
109
pub unsafe fn mut_object < ' a , T > ( pointer : * mut T ) -> & ' a mut T {
110
+ #[ cfg( any( feature = "panic-if-null" , debug_assertions) ) ]
107
111
panic_if_null ( pointer) ;
108
112
// CAUTION: this is unsafe
109
113
return & mut * pointer;
0 commit comments