mirror of
https://github.com/tuneinsight/lattigo.git
synced 2025-09-13 03:27:14 +00:00
23 lines
487 B
Go
23 lines
487 B
Go
package utils
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
cs "golang.org/x/exp/constraints"
|
|
)
|
|
|
|
type Number interface {
|
|
cs.Complex | cs.Float | cs.Integer
|
|
}
|
|
|
|
// Pointy creates a new T variable and returns its pointer.
|
|
func Pointy[T Number](x T) *T {
|
|
return &x
|
|
}
|
|
|
|
// PointyIntToPointUint64 converts *int to *uint64.
|
|
func PointyIntToPointUint64(x *int) *uint64 {
|
|
/* #nosec G103 -- behavior and consequences well understood, pointer type cast */
|
|
return (*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(x))))
|
|
}
|