mirror of
https://github.com/majd/ipatool
synced 2026-11-26 17:27:52 +08:00
25 lines
404 B
Go
25 lines
404 B
Go
package util
|
|
|
|
import "github.com/pkg/errors"
|
|
|
|
type Pair[T, U any] struct {
|
|
First T
|
|
Second U
|
|
}
|
|
|
|
func Zip[T, U any](ts []T, us []U) ([]Pair[T, U], error) {
|
|
if len(ts) != len(us) {
|
|
return nil, errors.New(ErrSlicesLengthMismatch.Error())
|
|
}
|
|
|
|
pairs := make([]Pair[T, U], len(ts))
|
|
for i := 0; i < len(ts); i++ {
|
|
pairs[i] = Pair[T, U]{
|
|
First: ts[i],
|
|
Second: us[i],
|
|
}
|
|
}
|
|
|
|
return pairs, nil
|
|
}
|