escape.mx raw

   1  package abi
   2  
   3  import "unsafe"
   4  
   5  // Tell the compiler the given pointer doesn't escape.
   6  // The compiler knows about this function and will give the nocapture parameter
   7  // attribute.
   8  func NoEscape(p unsafe.Pointer) unsafe.Pointer {
   9  	return p
  10  }
  11  
  12  func Escape[T any](x T) T {
  13  	// This function is either implemented in the compiler, or left undefined
  14  	// for some variation of T. The body of this function should not be compiled
  15  	// as-is.
  16  	panic("internal/abi.Escape: unreachable (implemented in the compiler)")
  17  }
  18