equality

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Overview

Package equality provides a type class for equality with some commonly used instances:

- Default implements the default comparison of Go

- Natural uses the Equal method defined on a type

- Slice can be used to create equality instances for slices

- StringIgnoreCase is an equality instance for strings that is not case-sensitive

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Equal

type Equal[T any] interface {
	Equal(other T) bool
}

Equal is an interface for types that provide an Equal method

type Equality

type Equality[T any] interface {
	Equal(a, b T) bool
}

Equality models a type class for types with equality

func Default

func Default[T comparable]() Equality[T]

Default equality on comparable types.

func Natural

func Natural[T Equal[T]]() Equality[T]

Natural equality on types that implement the Equal interface.

func Slice

func Slice[T any](e Equality[T]) Equality[[]T]

Slice equality, given equality for slice elements.

func SliceNatural

func SliceNatural[T Equal[T]]() Equality[[]T]

SliceNatural is equivalent to Slice(Natural[T]())

func StringIgnoreCase

func StringIgnoreCase() Equality[string]

StringIgnoreCase implements equality while treating upper- and lower-case letters as equivalent (using strings.EqualFold)

type Fun

type Fun[T any] func(a, b T) bool

Fun transforms an equality function into an Equality instance

func (Fun[T]) Equal

func (f Fun[T]) Equal(a, b T) bool

Jump to

Keyboard shortcuts

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