sugar

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any](slices []T, satisfied func(T) bool) []T

过滤列表

func Get

func Get[T comparable](value, dv T) T

带缺省值的赋值

func If

func If(cond bool, f func())

为了能将if一行写下而存在,适用于极简场景,其它情况下不要使用这个函数!

func IfExpr

func IfExpr[T any](cond bool, y, n T) T

if表达式

func In

func In[T comparable](elems []T, dest T) bool

func Map

func Map[T1, T2 any](slices []T1, deal func(T1) T2) []T2

将一个类型的列表转换成另一个类型的列表(全转换)

func Multi

func Multi[I, O any](inS []I, f Single[I, O]) []O

func Range

func Range[T any](elems []T, f func(T))

为了能将for range一行写下而存在,适用于极简场景,其它情况下不要使用这个函数!

func ToMap

func ToMap[K constraints.Integer | string, V any](slices []V, deal func(V) (K, V)) map[K]V

Types

type Single

type Single[I, O any] func(I) O

Jump to

Keyboard shortcuts

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