builtin

package
v0.0.0-...-dc70fb0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0, LGPL-3.0 Imports: 4 Imported by: 1

Documentation

Overview

builtin contains additional utility functions for built-in types of the Go programming languages. This package contains the utils that apply to types and functions that are always immediately available.

TODO consider adding function for "compacting" a map, i.e. copying content over into new map such that there is no memory wasted after intense use. TODO consider if we need to move slices and maps utils out to prevent `builtin` from growing too big.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add[T types.Number](a, b T) T

Add is a trivial func. It does not protect its boundaries, e.g. overflowing. It can be referenced, for example in `Reduce`.

func EqualsAny

func EqualsAny[T comparable](value T, matches ...T) bool

EqualsAny matches the specified value with any of the provided `matches` values. It returns `true` if it is any of the provided matches, or `false` if none match.

func Error

func Error[T any](result T, err error) error

Error drops the result, returning only the error

func Error2

func Error2[T, T2 any](result T, result2 T2, err error) error

Error2 drops two results, returning only the error

func Error3

func Error3[T, T2, T3 any](result T, result2 T2, result3 T3, err error) error

Error3 drops three results, returning only the error

func Error4

func Error4[T, T2, T3, T4 any](result T, result2 T2, result3 T3, result4 T4, err error) error

Error4 drops four results, returning only the error

func Expect

func Expect[T any](result T, err error) T

Expect checks for error and either panics on error, or passes through only the result.

func Expect2

func Expect2[T any, T2 any](result T, result2 T2, err error) (T, T2)

Expect2 checks for error and either panics on error, or passes through only the results.

func Expect3

func Expect3[T, T2, T3 any](result T, result2 T2, result3 T3, err error) (T, T2, T3)

Expect3 checks for error and either panics on error, or passes through only the results.

func Expect4

func Expect4[T, T2, T3, T4 any](result T, result2 T2, result3 T3, result4 T4, err error) (T, T2, T3, T4)

Expect4 checks for error and either panics on error, or passes through only the results.

func Multiply

func Multiply[T types.Number](a, b T) T

Multiply is a trivial func. It does not protect its boundaries, e.g. overflowing. It can be referenced, for example in `Reduce`.

func NonZero

func NonZero[T types.Number](v T) bool

NonZero tests whether provided value `v` is non-zero.

func RecoverLogged

func RecoverLogged(format string)

RecoverLogged recovers from panic and logs the payload. This function must be _deferred_ to be useful.

func RecoverLoggedStackTrace

func RecoverLoggedStackTrace(format string)

RecoverLoggedStackTrace calls `recover()` and in case the goroutine was indeed panicking, it writes the error message and a stack trace to os.Stderr. This function must be _deferred_ to be useful.

func Zero

func Zero[T types.Number](v T) bool

Zero tests whether provided value `v` is zero.

Types

This section is empty.

Directories

Path Synopsis
bitset is a package that provides a bit-wise set implementation for indexes/positions.
bitset is a package that provides a bit-wise set implementation for indexes/positions.
Multiset is a map with uint-values that represents a set of elements with their respective number of elements.
Multiset is a map with uint-values that represents a set of elements with their respective number of elements.
set is a map of keys with unit-values (`struct{}{}`).
set is a map of keys with unit-values (`struct{}{}`).

Jump to

Keyboard shortcuts

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