Documentation
¶
Index ¶
- func MapsUnion[K comparable, V any](a map[K]V, b map[K]V) map[K]V
- func NilCoalesce[T any](maybe *T, default_ T) T
- func NilCoalesceSlice[T any](maybe []T) []T
- func PointerIntegerCast[U constraints.Integer, T constraints.Integer](p *T) *U
- func PointerTo[T any](v T) *T
- func SaturatingSub[T constraints.Unsigned](a T, b T) T
- type SyncPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MapsUnion ¶
func MapsUnion[K comparable, V any](a map[K]V, b map[K]V) map[K]V
b has priority in case of key conflict with a
func NilCoalesce ¶
func NilCoalesce[T any](maybe *T, default_ T) T
func NilCoalesceSlice ¶
func NilCoalesceSlice[T any](maybe []T) []T
func PointerIntegerCast ¶
func PointerIntegerCast[U constraints.Integer, T constraints.Integer](p *T) *U
func SaturatingSub ¶
func SaturatingSub[T constraints.Unsigned](a T, b T) T
Types ¶
type SyncPool ¶
type SyncPool[T any] struct { // contains filtered or unexported fields }
SyncPool is a type-safe wrapper around sync.SyncPool using generics.
func NewSyncPool ¶
NewSyncPool creates a new type-safe pool. If newFunc is non-nil, it is used to generate new values when Get is called on an empty pool. If newFunc is nil, Get will return the zero value of T when the pool is empty.
func (*SyncPool[T]) Get ¶
func (p *SyncPool[T]) Get() T
Get returns a value from the pool. If the pool is empty and no New function was provided, it returns the zero value of T.
func (*SyncPool[T]) WithPoolItem ¶
func (p *SyncPool[T]) WithPoolItem(f func(T))
Click to show internal directories.
Click to hide internal directories.