decode

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Converter

type Converter[I any, W any] struct {
	// contains filtered or unexported fields
}

Converter is a reusable object that knows how to convert a collection of items (from a map or slice) into a final wrapped structure.

func NewConverter

func NewConverter[I any, W any](
	namer func(name string, item I) (I, bool),
	wrap func(items []I) W,
) *Converter[I, W]

NewConverter creates a new, reusable converter. The namer and wrap functions are defined only once.

func (*Converter[I, W]) FromMap

func (c *Converter[I, W]) FromMap(m map[string]I) W

FromMap executes the conversion from a map. It now correctly handles empty maps.

func (*Converter[I, W]) FromSlice

func (c *Converter[I, W]) FromSlice(s []I) W

FromSlice executes the conversion from a slice. It now correctly handles empty slices, ensuring consistent behavior with FromMap.

Jump to

Keyboard shortcuts

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