ch1

package
v0.0.0-...-6eb9459 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestReadWriterCloser

func TestReadWriterCloser[RWC ReadWriterCloser](rw RWC)

func TestToString

func TestToString()

func ToString

func ToString[T SignedToString](t T) string

Types

type AllInt

type AllInt interface {
	int | int8 | int16 | int32 | int64
}

type Empty

type Empty interface {
	int
	float64
}

空类型

type Int

type Int interface {
	int
}

类型约束

type IntOrFloat64

type IntOrFloat64 interface {
	~int | ~float64
}

type IntToString

type IntToString int

类型约束不能再当做普通的接口,只能用作类型约束

func (IntToString) ToString

func (it IntToString) ToString() string

type List

type List[T any] struct {
	// contains filtered or unexported fields
}

泛型类型

func (*List[T]) Len

func (l *List[T]) Len() int

泛型类型的方法

func (*List[V]) Size

func (l *List[V]) Size() int

type MyFunc

type MyFunc[T constraints.Ordered, V any] func(T) V

--------------------------- 泛型方法的扩展

type MyList

type MyList[T any] List[T]

type MyList2

type MyList2 List[int]

type MyMap

type MyMap[K comparable, V any] map[K]V

type MyMap2

type MyMap2[K comparable] map[K]int

type ReadWriterCloser

type ReadWriterCloser interface {
	*os.File | *net.TCPConn | *net.UDPConn | *net.UnixConn | *net.IPConn

	io.Reader
	io.Writer
	io.Closer
}

嵌入接口

type S1

type S1[P any] struct{}

--------------------------- 泛型类型的扩展

type S2

type S2[S interface{ ~[]byte | string }] struct{}

--------------------------- 泛型类型的扩展

type S3

type S3[S ~[]E, E any] struct{}

--------------------------- 泛型类型的扩展

type S4

type S4[P S1[int]] struct{}

--------------------------- 泛型类型的扩展

type S5

type S5[_ any] struct{}

--------------------------- 泛型类型的扩展

type S6

type S6[_ any, _ io.Reader] struct{}

--------------------------- 泛型类型的扩展

type S7

type S7[K any, _ io.Reader, V any] struct{}

--------------------------- 泛型类型的扩展

type S8

type S8[K, _ any, S, T S4[S1[int]]] struct{}

--------------------------- 泛型类型的扩展

type S9

type S9[K int, T map[K]any] struct{}

--------------------------- 泛型类型的扩展

type Signed

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

type SignedToString

type SignedToString interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64

	ToString() string
}

Jump to

Keyboard shortcuts

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