@@ -24,6 +24,7 @@ use std::boxed::Box;
2424#[ cfg( all( feature = "std" , feature = "c-types" ) ) ]
2525pub mod c;
2626
27+ #[ cfg( any( feature = "panic-if-null" , debug_assertions) ) ]
2728#[ inline]
2829fn panic_if_null < T > ( pointer : * const T ) {
2930 if pointer. is_null ( ) {
@@ -69,6 +70,7 @@ pub unsafe fn free<T>(pointer: *mut T) {
6970#[ cfg( any( feature = "alloc" , feature = "std" ) ) ]
7071#[ inline]
7172pub unsafe fn own_back < T > ( pointer : * mut T ) -> T {
73+ #[ cfg( any( feature = "panic-if-null" , debug_assertions) ) ]
7274 panic_if_null ( pointer) ;
7375 // CAUTION: this is unsafe
7476 let boxed = Box :: from_raw ( pointer) ;
@@ -87,6 +89,7 @@ pub unsafe fn own_back<T>(pointer: *mut T) -> T {
8789/// That could produce a HEAP error that produce a crash.
8890#[ inline]
8991pub unsafe fn object < ' a , T > ( pointer : * const T ) -> & ' a T {
92+ #[ cfg( any( feature = "panic-if-null" , debug_assertions) ) ]
9093 panic_if_null ( pointer) ;
9194 // CAUTION: this is unsafe
9295 return & * pointer;
@@ -104,6 +107,7 @@ pub unsafe fn object<'a, T>(pointer: *const T) -> &'a T {
104107/// That could produce a HEAP error that produce a crash.
105108#[ inline]
106109pub unsafe fn mut_object < ' a , T > ( pointer : * mut T ) -> & ' a mut T {
110+ #[ cfg( any( feature = "panic-if-null" , debug_assertions) ) ]
107111 panic_if_null ( pointer) ;
108112 // CAUTION: this is unsafe
109113 return & mut * pointer;
0 commit comments