slice

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any](in []T, fn func(T) bool) []T

Filter filters the input slice using the provided filter function.

func IgnoreErr added in v0.3.0

func IgnoreErr[S []T, T any](s S, err error) S

IgnoreErr[S []T, T any](s S, err error) S

IgnoreErr returns the input slice without modifying it. It is used to ignore errors that may be returned from a function call. The function takes in a slice of any type and an error value, and returns the same slice as input.

func Map

func Map[In, Out any](in []In, fn func(In) Out) []Out

Map maps the input slice using the provided mapper function.

func MapErr added in v0.3.0

func MapErr[In, Out any](in []In, fn func(In) (Out, error)) ([]Out, error)

MapErr maps the input slice using the provided mapper function that returns an Out and an error. It returns a new slice of type Out and an error if any occurred during execution. [In] represents the type of input slice and [Out] represents the type of output slice.

func Unique

func Unique[In ~[]T, T comparable](in In) []T

Unique returns a new slice containing the unique elements of the input slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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