slice

package
v3.113.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 0 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Map added in v3.107.0

func Map[T, U any](s []T, f func(T) U) []U

Map applies the given function to each element of the given slice and returns a new slice with the results.

func MapError added in v3.107.0

func MapError[T, U any](s []T, f func(T) (U, error)) ([]U, error)

MapError applies the given function to each element of the given slice and returns a new slice with the results. If any element returns an error that error is returned, as well as the slice of results so far.

func Prealloc

func Prealloc[T any](capacity int) []T

Preallocates a slice of type T of a given length. If the input length is 0 then the returned slice will be nil. We prefer this over `make([]T, 0, length)` because nil is often treated semantically different from an empty slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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