xslices

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any](s []T, f func(T) bool) []T

Filter filters the slice to only the values where f returns true.

func FilterError

func FilterError[T any](s []T, f func(T) (bool, error)) ([]T, error)

FilterError filters the slice to only the values where f returns true.

Returns error the first time f returns error.

func Map

func Map[T1, T2 any](s []T1, f func(T1) T2) []T2

Map maps the slice.

func MapError

func MapError[T1, T2 any](s []T1, f func(T1) (T2, error)) ([]T2, error)

MapError maps the slice.

Returns error the first time f returns error.

func MapKeysToSlice

func MapKeysToSlice[K comparable, V any](m map[K]V) []K

MapKeysToSlice converts the map's keys to a slice.

func MapKeysToSortedSlice

func MapKeysToSortedSlice[M ~map[K]V, K cmp.Ordered, V any](m M) []K

MapKeysToSortedSlice converts the map's keys to a sorted slice.

func ToStructMap

func ToStructMap[T comparable](s []T) map[T]struct{}

ToStructMap converts the slice to a map with struct{} values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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