Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantv committed Jul 31, 2023
1 parent 3c9d2e9 commit 339ed81
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions field.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,14 @@ func Inline(val zapcore.ObjectMarshaler) Field {
}
}

type anyFuncType func(string, any) Field

func typedToAnyFunc[T any](f func(string, T) Field) anyFuncType {
return func(k string, v any) Field {
return f(k, v.(T))
}
}

// anyTypeLookup is a map from concrete types to the field constructors.
var anyTypeLookup = buildAnyTypeLookup()
var anyInterfaceLookup = []struct {
Expand All @@ -435,14 +443,6 @@ var anyInterfaceLookup = []struct {
},
}

type anyFuncType func(string, any) Field

func typedToAnyFunc[T any](f func(string, T) Field) anyFuncType {
return func(k string, v any) Field {
return f(k, v.(T))
}
}

func addTypeLookup[T any](
m map[reflect.Type]anyFuncType,
directTypeFn func(string, T) Field,
Expand Down

0 comments on commit 339ed81

Please sign in to comment.