github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/ekaext/constraints.go (about)

     1  // Copyright © 2020-2021. All rights reserved.
     2  // Author: Ilya Stroy.
     3  // Contacts: iyuryevich@pm.me, https://github.com/qioalice
     4  // License: https://opensource.org/licenses/MIT
     5  
     6  package ekaext
     7  
     8  // This file is a extended variant of golang.org/x/exp/constraints package.
     9  // Original rights are belong to that package's authors.
    10  
    11  // Signed is a constraint that permits any signed integer type.
    12  type Signed interface {
    13  	~int | ~int8 | ~int16 | ~int32 | ~int64
    14  }
    15  
    16  // Unsigned is a constraint that permits any unsigned integer type.
    17  type Unsigned interface {
    18  	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
    19  }
    20  
    21  // Integer is a constraint that permits any integer type.
    22  type Integer interface {
    23  	Signed | Unsigned
    24  }
    25  
    26  // Float is a constraint that permits any floating-point type.
    27  type Float interface {
    28  	~float32 | ~float64
    29  }
    30  
    31  // Complex is a constraint that permits any complex numeric type.
    32  type Complex interface {
    33  	~complex64 | ~complex128
    34  }
    35  
    36  // Numeric is a constraint that permits any of Integer or Float numeric types.
    37  type Numeric interface {
    38  	Integer | Float
    39  }
    40  
    41  // Ordered is a constraint that permits any ordered type: any type
    42  // that supports the operators < <= >= >.
    43  type Ordered interface {
    44  	Integer | Float | ~string
    45  }