constraints

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package constraints defines a set of useful constraints to be used with type parameters. This package was called "constriants" and was removed from the Go standard library before the 1.18 release, but is reproduced here inside the fn library because we need the numeric types. See https://github.com/golang/go/issues/50792

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arithmetic

type Arithmetic interface {
	Integer | Float | Complex
}

Arithmetic is the type union of all numeric types.

type Complex

type Complex interface {
	~complex64 | ~complex128
}

Complex is a constraint that permits any complex numeric type.

type Float

type Float interface {
	~float32 | ~float64
}

Float is a constraint that permits any floating-point type.

type Integer

type Integer interface {
	Signed | Unsigned
}

Integer is a constraint that permits any integer type.

type Ordered

type Ordered interface {
	Integer | Float | ~string
}

Ordered is a constraint that permits any ordered type: any type that supports the operators < <= >= >.

type Signed

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

Signed is a constraint that permits any signed integer type.

type Unsigned

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Unsigned is a constraint that permits any unsigned integer type.

Jump to

Keyboard shortcuts

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