tiered

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package tiered provides a type for a tiered set of objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tiered

type Tiered[T any] struct {

	// First is the object that will be used first,
	// before [Tiered.Normal] and [Tiered.Final].
	First T

	// Normal is the object that will be used at the normal
	// time, after [Tiered.First] and before [Tiered.Final].
	Normal T

	// Final is the object that will be used last,
	// after [Tiered.First] and [Tiered.Normal].
	Final T
}

Tiered represents a tiered set of objects of the same type. For example, this is frequently used to represent slices of functions that can be run at the first, normal, or final time.

func (*Tiered[T]) Do

func (t *Tiered[T]) Do(f func(T))

Do calls the given function for each tier, going through first, then normal, then final.

func (*Tiered[T]) DoWith

func (t *Tiered[T]) DoWith(other *Tiered[T], f func(*T, *T))

DoWith calls the given function with each tier of this tiered set and the other given tiered set, going through first, then normal, then final.

Jump to

Keyboard shortcuts

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