sliceconv

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 1 Imported by: 0

README

Sliceconv

Sliceconv is a go library for converting slices from one type to another.

Integer

Integer converts any integer-based slice to any other integer-based slice. No overflow checks.

func Integer[T1 constraints.Integer, T2 constraints.Integer](from []T1) []T2{}

Float

Float converts any float-based slice to any other float-based slice. No overflow checks.

func Float[T1 constraints.Float, T2 constraints.Float](from []T1) []T2 {}

Examples

Integer

Standard types:

	from := []int32{1, 2, 3}
	to := Integer[int32, int64](from)

User defined types:

	type protoPlatform uint32
	type sdkPlatform uint8
	const (
		IOS sdkPlatform = iota + 1
		Android
		Windows
		Web
	)
	from := []sdkPlatform{IOS, Android, Windows}
	to := Integer[sdkPlatform, protoPlatform](from)

Float

    from := []float32{1.1, 2.2, 3.3}
    to := Float[float32, float64](from)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float

func Float[T1 constraints.Float, T2 constraints.Float](from []T1) []T2

Float converts any float-based slice to any other float-based slice. No overflow checks.

func Integer

func Integer[T1 constraints.Integer, T2 constraints.Integer](from []T1) []T2

Integer converts any integer-based slice to any other integer-based slice. No overflow checks.

Types

This section is empty.

Jump to

Keyboard shortcuts

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