constraints

package module
v0.0.0-...-96e5f4f Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 0 Imported by: 12

Documentation

Overview

Package constraints 参照 golang.org/x/exp/constraints, 但后者迭代太快经常使用新版本, 因此放弃此依赖转而自己写一个

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T Signed | Float](x T) T

Abs 返回绝对值

func Max

func Max[T Ordered](a, b T) T

Max 返回两个数中的最大值, 实际上在 1.21 开始就已经有内置的 max 了, 以防开发者不知道

func Min

func Min[T Ordered](a, b T) T

Min 返回两个数中的最小值, 实际上在 1.21 开始就已经有内置的 min 了, 以防开发者不知道

Types

type Complex

type Complex interface {
	~complex64 | ~complex128
}

type Float

type Float interface {
	~float32 | ~float64
}

type Integer

type Integer interface {
	Signed | Unsigned
}

type Ordered

type Ordered interface {
	Integer | Float | ~string
}

type Signed

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

type Unsigned

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

Jump to

Keyboard shortcuts

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