three

package
v0.0.0-...-27d85d3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package three provides a 3-tuple type.

Example
package main

import (
	"fmt"

	"github.com/binaryphile/valor/tuple/three"
)

func get() (string, int, float32, bool) {
	return "a", 1, 1.0, true
}

func main() {
	val := three.TupleValueOf(get())
	fmt.Println(val)
}
Output:

{{a 1 1} true}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func TupleResultOf

func TupleResultOf[T, T2, T3 any](v T, v2 T2, v3 T3, err error) result.Result[Tuple[T, T2, T3]]

TupleResultOf creates a result.Result of either (v, v2, v3) or err. This aids interoperability with function return values.

func TupleValueOf

func TupleValueOf[T, T2, T3 any](v T, v2 T2, v3 T3, ok bool) optional.Value[Tuple[T, T2, T3]]

TupleValueOf creates an optional.Value of (v, v2, v3) if ok is true. This aids interoperability with return values that follow the "comma ok" idiom.

Types

type Tuple

type Tuple[T, T2, T3 any] struct {
	V  T
	V2 T2
	V3 T3
}

Tuple contains three values.

func TupleMap

func TupleMap[T, T2, T3, Tp, T2p, T3p any](t Tuple[T, T2, T3], f func(T) Tp, f2 func(T2) T2p, f3 func(T3) T3p) Tuple[Tp, T2p, T3p]

TupleMap returns a Tuple with each value replaced by the result of each function.

funcs.Ident can be used to leave the value unchanged.

func TupleOf

func TupleOf[T, T2, T3 any](v T, v2 T2, v3 T3) Tuple[T, T2, T3]

TupleOf creates a Tuple of (v, v2, v3).

func (Tuple[T, T2, T3]) Values

func (t Tuple[T, T2, T3]) Values() (v T, v2 T2, v3 T3)

Values returns the contained values. This aids in assigning to variables or function arguments.

Jump to

Keyboard shortcuts

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