From 4e6f769cf6ea8fbb7a9569cdf5efba46b0ea0c01 Mon Sep 17 00:00:00 2001 From: ktong Date: Mon, 26 Aug 2024 09:12:56 -0700 Subject: [PATCH] use TypeFor --- internal/convert/option.go | 4 ++-- internal/nocopy.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/convert/option.go b/internal/convert/option.go index 7437e6a7..f65ee3fc 100644 --- a/internal/convert/option.go +++ b/internal/convert/option.go @@ -46,8 +46,8 @@ func withHookFunc[F, T any](hookFunc func(F, T) error) Option { } options.hooks = append(options.hooks, hook{ - fromType: reflect.TypeOf((*F)(nil)).Elem(), - toType: reflect.TypeOf((*T)(nil)).Elem(), + fromType: reflect.TypeFor[F](), + toType: reflect.TypeFor[T](), hook: func(f, t any) error { from, ok := f.(F) if !ok { diff --git a/internal/nocopy.go b/internal/nocopy.go index 09958a62..b024d714 100644 --- a/internal/nocopy.go +++ b/internal/nocopy.go @@ -17,6 +17,6 @@ func (c *NoCopy[T]) Check() { } if c.addr != c { - panic("illegal use of non-zero " + reflect.TypeOf((*T)(nil)).Elem().Name() + " copied by value") + panic("illegal use of non-zero " + reflect.TypeFor[T]().Name() + " copied by value") } }