Documentation
¶
Index ¶
- Variables
- func Assert(t *testing.T, cond bool)
- func AssertEq[T comparable](t *testing.T, a, b T)
- func AssertSliceEq[S ~[]E, E comparable](t *testing.T, a, b S)
- func CastOr[T any](x any, or T) T
- func Check(err error)
- func Clamp[T cmp.Ordered](x T, lo T, hi T) T
- func DerefOr[T any](ref *T, or T) T
- func DerefZero[T any](ref *T) T
- func Must[T any](t T, err error) T
- func Or[T comparable](vals ...T) T
- func Ptr[T any](t T) *T
- func Pull[V any](seq Seq[V]) (next func() (V, bool), stop func())
- func Pull2[K comparable, V any](seq Seq2[K, V]) (next func() (K, V, bool), stop func())
- func Ternary[T any](cond bool, a T, b T) T
- type Complex
- type Float
- type Integer
- type KeyValue
- type Nilable
- type Numeric
- type Ordered
- type Seq
- type Seq2
- type Seq2Func
- type SeqFunc
- type Signed
- type Unsigned
Constants ¶
This section is empty.
Variables ¶
View Source
var GlobalErrorHandler = func(err error) bool { panic(err) }
Functions ¶
func AssertEq ¶
func AssertEq[T comparable](t *testing.T, a, b T)
func AssertSliceEq ¶
func AssertSliceEq[S ~[]E, E comparable](t *testing.T, a, b S)
func DerefOr ¶
func DerefOr[T any](ref *T, or T) T
DerefOr dereferences the passed pointer otherwise returns the or value
func DerefZero ¶
func DerefZero[T any](ref *T) T
DerefZero is like DerefOr but returns the zero value if nil
func Pull2 ¶
func Pull2[K comparable, V any](seq Seq2[K, V]) (next func() (K, V, bool), stop func())
Pull2 is a wrapper around iter.Pull2
Types ¶
type Complex ¶
type Complex = constraints.Complex
type Float ¶
type Float = constraints.Float
type Integer ¶
type Integer = constraints.Integer
type KeyValue ¶
type KeyValue[K comparable, V any] struct { Key K Value V }
KeyValue is a key-value pair
type Ordered ¶
type Ordered = constraints.Ordered
type Seq ¶
type Seq[V any] interface { // Seq implements push-style iteration using the yield callback. // See the documenation of [iter] for more information. // It has exactly the same signature as [SeqFunc]. // This function can be used directly with the for-range statement Seq(yield func(V) bool) }
Seq borrows a trick used by [http.Handler] to define an interface and a func that implements that interface by calling itself SeqFunc
type Seq2 ¶
type Seq2[K comparable, V any] interface { // I don't like the whole [iter.Seq2] thing that the stdlib does // so we use this to convert [Seq2] into [Seq] // This trivially gives compatibility with the rest of this library Seq(yield func(KeyValue[K, V]) bool) Seq2(yield func(K, V) bool) }
Seq2 is to Seq what iter.Seq is to iter.Seq2 but with the additional requirement that Seq2 implements Seq
type Seq2Func ¶
type Seq2Func[K comparable, V any] iter.Seq2[K, V]
Seq2Func is exactly the same as iter.Seq2 and can be trivially cast between.
type Signed ¶
type Signed = constraints.Signed
type Unsigned ¶
type Unsigned = constraints.Unsigned
Click to show internal directories.
Click to hide internal directories.