util

package
v0.0.0-...-c101335 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

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 PointerTo

func PointerTo[T any](v T) *T

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

func NewSyncPool[T any](newFunc func() T) *SyncPool[T]

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]) Put

func (p *SyncPool[T]) Put(x T)

func (*SyncPool[T]) WithPoolItem

func (p *SyncPool[T]) WithPoolItem(f func(T))

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL