nonzero

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

Add returns None if the result is 0

func TryNewValue

func TryNewValue[T constraints.Float | constraints.Integer](x T) option.Option[NonZero[T]]

TryNewValue returns None if the given value is Zero

Types

type NonZero

type NonZero[T constraints.Float | constraints.Integer] struct {
	// contains filtered or unexported fields
}

NonZero a newtype that ensures the value encapsulated is not zero; the value encapsulated can be off integer or float for the approx type constraint, see: https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md

func UnsafeNewValue

func UnsafeNewValue[T constraints.Float | constraints.Integer](x T) NonZero[T]

UnsafeNewValue crashes if the given value is zero

func (NonZero[T]) Unwrap

func (val NonZero[T]) Unwrap() T

Jump to

Keyboard shortcuts

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