Documentation
¶
Index ¶
- func ConvertToSliceOfAny[T any](ts []T) (ret []any)
- func InitNew[T any](p **T)
- func MakeChanWithLen[T chan U, U any, L constraints.Integer](m *T, l L)
- func MakeMap[K comparable, V any, M ~map[K]V](pm *M)
- func MakeMapIfNil[K comparable, V any, M ~map[K]V](pm *M)
- func MakeMapIfNilAndSet[K comparable, V any](pm *map[K]V, k K, v V) (added bool)deprecated
- func MakeMapIfNilWithCap[K comparable, V any, M ~map[K]V, C constraints.Integer](pm *M, cap C)
- func MakeMapWithCap[K comparable, V any, M ~map[K]V, C constraints.Integer](pm *M, cap C)
- func MakeSliceWithCap[T any, L constraints.Integer](slice *[]T, cap L)
- func MakeSliceWithLength[T any, L constraints.Integer](slice *[]T, length L)
- func MapContains[K comparable, V any, M ~map[K]V](m M, k K) bool
- func MapMustAssignNew[K comparable, V any, M ~map[K]V](m M, k K, v V)
- func MapMustGet[K comparable, V any, M ~map[K]V](m M, k K) V
- func Max[T constraints.Ordered](a, b T) T
- func Min[T constraints.Ordered](a, b T) T
- func MustDelete[K comparable, V any, M ~map[K]V](m M, k K)
- func PtrTo[T any](t T) *T
- func Range[T constraints.Integer](n T) []struct{}
- func ReverseSlice[T any](slice []T)
- func Reversed[T any](slice []T) []T
- func SetZero[T any](p *T)
- func Singleton[T any](t T) []T
- func SliceDrop[T any](n int, slice []T) []T
- func SliceMap[From, To any](froms []From, convert func(From) To) []To
- func SlicePop[T any](slice *[]T) T
- func SliceTake[T any](n int, slice []T) []T
- func UnwrapErrorTuple[T any](t T, err error) T
- func ZeroValue[T any]() (zero T)
- type Future
- type Option
- func (me Option[V]) AndThen(f func(V) Option[V]) Option[V]deprecated
- func (me Option[V]) AsTuple() (V, bool)
- func (me Option[V]) Or(or Option[V]) Option[V]
- func (me *Option[V]) Set(v V) (prev Option[V])
- func (me *Option[V]) SetFromTuple(v V, ok bool)
- func (me *Option[V]) SetNone()
- func (me *Option[V]) SetSomeZeroValue()
- func (me Option[V]) String() string
- func (me Option[V]) ToPtr() *V
- func (me Option[V]) Unwrap() V
- func (me Option[V]) UnwrapOr(or V) V
- func (me Option[V]) UnwrapOrZeroValue() (_ V)
- func (me *Option[V]) UnwrapPtr() *V
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToSliceOfAny ¶
I take it there's no way to do this with a generic return slice element type.
func MakeChanWithLen ¶
func MakeChanWithLen[T chan U, U any, L constraints.Integer](m *T, l L)
I can't seem to make a common function for things the make function works with. "no core type"
func MakeMap ¶
func MakeMap[K comparable, V any, M ~map[K]V](pm *M)
Does this exist in the maps package?
func MakeMapIfNil ¶
func MakeMapIfNil[K comparable, V any, M ~map[K]V](pm *M)
func MakeMapIfNilAndSet
deprecated
func MakeMapIfNilAndSet[K comparable, V any](pm *map[K]V, k K, v V) (added bool)
Deprecated: Use MakeMapIfNil and MapInsert separately.
func MakeMapIfNilWithCap ¶ added in v0.0.3
func MakeMapIfNilWithCap[K comparable, V any, M ~map[K]V, C constraints.Integer](pm *M, cap C)
func MakeMapWithCap ¶
func MakeMapWithCap[K comparable, V any, M ~map[K]V, C constraints.Integer](pm *M, cap C)
func MakeSliceWithCap ¶
func MakeSliceWithCap[T any, L constraints.Integer](slice *[]T, cap L)
func MakeSliceWithLength ¶
func MakeSliceWithLength[T any, L constraints.Integer](slice *[]T, length L)
func MapContains ¶
func MapContains[K comparable, V any, M ~map[K]V](m M, k K) bool
func MapMustAssignNew ¶ added in v0.0.3
func MapMustAssignNew[K comparable, V any, M ~map[K]V](m M, k K, v V)
Panics if the key is already assigned in the map.
func MapMustGet ¶
func MapMustGet[K comparable, V any, M ~map[K]V](m M, k K) V
func Max ¶
func Max[T constraints.Ordered](a, b T) T
func Min ¶
func Min[T constraints.Ordered](a, b T) T
func MustDelete ¶ added in v0.0.3
func MustDelete[K comparable, V any, M ~map[K]V](m M, k K)
Deletes element with the key k. If there is no element with the specified key, panics. delete only applies to maps, so for now Map is not mentioned in the function name.
func Range ¶
func Range[T constraints.Integer](n T) []struct{}
Returns a zero-size, zero-allocation slice of the given length that can be used with range to loop n times. Also has the advantage of not requiring a loop variable. Similar to bradfitz's iter.N, and my clone in anacrolix/missinggo.
func ReverseSlice ¶
func ReverseSlice[T any](slice []T)
func SliceMap ¶
func SliceMap[From, To any](froms []From, convert func(From) To) []To
Surely you should just pass iterator functions around instead. Go sux.
func SlicePop ¶
func SlicePop[T any](slice *[]T) T
Pops the last element from the slice and returns it. Panics if the slice is empty, or if the slice is nil.
func UnwrapErrorTuple ¶
Types ¶
type Option ¶
type Option[V any] struct { // Value must be zeroed when Ok is false for deterministic comparability. Value V // bool is the smallest type, so putting it at the end increases the chance it can be packed // with Value. Ok bool }
func MapInsert ¶
func MapInsert[K comparable, V any, M ~map[K]V](m M, k K, v V) Option[V]
Returns Some of the previous value if there was one.
func OptionFromTuple ¶
func (Option[V]) Or ¶ added in v0.0.3
Returns an Option that is the left Option if it's Some else the right Option.
func (*Option[V]) SetFromTuple ¶
func (*Option[V]) SetSomeZeroValue ¶
func (me *Option[V]) SetSomeZeroValue()
func (Option[V]) ToPtr ¶ added in v0.0.3
func (me Option[V]) ToPtr() *V
Converts the option to an option expressed as a pointer (old-school nonsense).
func (Option[V]) UnwrapOrZeroValue ¶
func (me Option[V]) UnwrapOrZeroValue() (_ V)
type Result ¶
func ResultFromTuple ¶
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package heap provides heap operations for any type that implements heap.Interface.
|
Package heap provides heap operations for any type that implements heap.Interface. |
Package list implements a doubly linked list.
|
Package list implements a doubly linked list. |