Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add[T constraints.Float | constraints.Integer](lhs NonZero[T], rhs NonZero[T]) option.Option[NonZero[T]]
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
Click to show internal directories.
Click to hide internal directories.