subtract

package
v0.0.0-...-6c4fd92 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: NIST-PD-fallback Imports: 1 Imported by: 0

Documentation

Overview

Package subtract computes struct numerical difference.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sub

func Sub[T any](curr, prev T) (diff T)

Sub computes the numerical difference between two structs of the same type. It returns the result in a new instance of the same type, and does not modify the arguments.

If the struct has `func (T) Sub(T) T` method, it is used; otherwise, this calls SubFields.

func SubFields

func SubFields[T any](curr, prev T, diffPtr *T)

SubFields computes the numerical difference between two structs of the same type. It assigns the result to a pointer to the same type.

This function can handle these field types:

  • unsigned/signed integer.
  • struct (recursive).
  • slice (recursive, truncated to the shorter slice).
  • array (recursive).

Other fields are ignored. A field may be explicitly skipped with `subtract:"-"` tag.

Types

This section is empty.

Jump to

Keyboard shortcuts

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