31 lines
469 B
Go
31 lines
469 B
Go
//go:build go1.18
|
|
// +build go1.18
|
|
|
|
package zerolog
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func AsLogObjectMarshalers[T LogObjectMarshaler](objs []T) []LogObjectMarshaler {
|
|
if objs == nil {
|
|
return nil
|
|
}
|
|
s := make([]LogObjectMarshaler, len(objs))
|
|
for i, v := range objs {
|
|
s[i] = v
|
|
}
|
|
return s
|
|
}
|
|
|
|
func AsStringers[T fmt.Stringer](objs []T) []fmt.Stringer {
|
|
if objs == nil {
|
|
return nil
|
|
}
|
|
s := make([]fmt.Stringer, len(objs))
|
|
for i, v := range objs {
|
|
s[i] = v
|
|
}
|
|
return s
|
|
}
|