tuple

package
v2.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package tuple simplifies packing and unpacking function arguments and results into generic tuple types.

Example
package main

import (
	"github.com/tawesoft/golib/v2/must"
	"github.com/tawesoft/golib/v2/tuple"
)

func main() {
	// types inferred implicitly
	a := tuple.ToT2(5, true)
	b := tuple.ToT2(7, true)
	must.Not(a == b)

	// explicitly typed
	c := tuple.ToT2[int32, bool](5, true)
	d := tuple.ToT2[int32, bool](7, true)
	must.Not(c == d)

}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type T2

type T2[A any, B any] struct {
	A A
	B B
}

func ToT2

func ToT2[A any, B any](a A, b B) T2[A, B]

func (*T2[A, B]) Unpack

func (t *T2[A, B]) Unpack() (A, B)

type T3

type T3[A any, B any, C any] struct {
	A A
	B B
	C C
}

func ToT3

func ToT3[A any, B any, C any](a A, b B, c C) T3[A, B, C]

func (*T3[A, B, C]) Unpack

func (t *T3[A, B, C]) Unpack() (A, B, C)

type T4

type T4[A any, B any, C any, D any] struct {
	A A
	B B
	C C
	D D
}

func ToT4

func ToT4[A any, B any, C any, D any](a A, b B, c C, d D) T4[A, B, C, D]

func (*T4[A, B, C, D]) Unpack

func (t *T4[A, B, C, D]) Unpack() (A, B, C, D)

Jump to

Keyboard shortcuts

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