misc

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 1 Imported by: 17

README

Misc

A set of types and functions that don't fit into other packages and which are useful for nearly any project.

Optional

This package provides a type Optional which is a wrapper around a value that may or may not be present. It is similar to Java's Optional or Ruby's Maybe type.

Alternative to using this package is storing the value as a pointer and checking for nil value, but that approach increases number of memory indirections and risks null pointer dereference.

Functions

This package provides a set of common function and function types. Some of them were created just for my own needs, but most of them are needed for "every day" programming (predicates, comparators, etc.).

Pair

Simple generic type that holds two values of any type.

Math

Currently, only contains numeric type constraints that can be useful for generic math functions and structures.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloner

type Cloner[T any] interface {
	Clone() T
}

type Pair

type Pair[T1 any, T2 any] struct {
	First  T1
	Second T2
}

func MakePair added in v1.0.5

func MakePair[T1, T2 any](first T1, second T2) Pair[T1, T2]

func (Pair[T1, T2]) Get added in v1.0.0

func (pair Pair[T1, T2]) Get() (T1, T2)

func (Pair[T1, T2]) String added in v1.0.2

func (pair Pair[T1, T2]) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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