constraints

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 0 Imported by: 1

README

AtomicGo | constraints

Downloads Latest Release Tests Coverage Unit test count Go report


Documentation | Contributing | Code of Conduct


AtomicGo

go get atomicgo.dev/constraints

constraints

import "atomicgo.dev/constraints"

Package constraints provides constraints for type parameters aka. generics in Go.

This is a more comprehensive drop-in replacement for golang.org/x/exp/constraints.

Index

type Addable

Addable is a constraint that matches any type that can be added with the + operator.

type Addable interface {
    Number | ~string
}

type Comparable

Comparable is a constraint that matches any type that can be compared with the == and != operators.

type Comparable interface {
    comparable
}

type Complex

Complex is a constraint that matches any complex number type.

type Complex interface {
    ~complex64 | ~complex128
}

type Float

Float is a constraint that matches any floating point number type.

type Float interface {
    ~float32 | ~float64
}

type Integer

Integer is a constraint that matches any integer type.

type Integer interface {
    Signed | Unsigned
}

type Number

Number is a constraint that matches any real number type. The Number constraint does not include Complex numbers, as those are not ordered. If you also need Complex numbers, use the Numeric constraint.

type Number interface {
    Float | Integer
}

type Numeric

Numeric is a constraint that matches any numeric type, including complex numbers.

type Numeric interface {
    Number | Complex
}

type Orderable

Orderable is a constraint that matches any type that can be ordered with the <, <=, >, and >= operators.

type Orderable interface {
    Integer | Float | ~string
}

type Ordered

Ordered is a constraint that matches any ordered type.

type Ordered interface {
    Integer | Float | ~string
}

type Signed

Signed is a constraint that matches any signed integer type.

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

type Unsigned

Unsigned is a constraint that matches any unsigned integer type.

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

Generated by gomarkdoc


AtomicGo.dev  ·  with ❤️ by @MarvinJWendt | MarvinJWendt.com

Documentation

Overview

Package constraints provides constraints for type parameters aka. generics in Go.

This is a more comprehensive drop-in replacement for golang.org/x/exp/constraints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addable

type Addable interface {
	Number | ~string
}

Addable is a constraint that matches any type that can be added with the + operator.

type Comparable

type Comparable interface {
	comparable
}

Comparable is a constraint that matches any type that can be compared with the == and != operators.

type Complex

type Complex interface {
	~complex64 | ~complex128
}

Complex is a constraint that matches any complex number type.

type Float

type Float interface {
	~float32 | ~float64
}

Float is a constraint that matches any floating point number type.

type Integer

type Integer interface {
	Signed | Unsigned
}

Integer is a constraint that matches any integer type.

type Number

type Number interface {
	Float | Integer
}

Number is a constraint that matches any real number type. The Number constraint does not include Complex numbers, as those are not ordered. If you also need Complex numbers, use the Numeric constraint.

type Numeric

type Numeric interface {
	Number | Complex
}

Numeric is a constraint that matches any numeric type, including complex numbers.

type Orderable

type Orderable interface {
	Integer | Float | ~string
}

Orderable is a constraint that matches any type that can be ordered with the <, <=, >, and >= operators.

type Ordered

type Ordered interface {
	Integer | Float | ~string
}

Ordered is a constraint that matches any ordered type.

type Signed

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

Signed is a constraint that matches any signed integer type.

type Unsigned

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

Unsigned is a constraint that matches any unsigned integer type.

Jump to

Keyboard shortcuts

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