From a7900ffa1ba5655a5fad903c6634c888d3025d86 Mon Sep 17 00:00:00 2001 From: Chris Wendt Date: Wed, 8 Jun 2022 03:18:43 -0600 Subject: eliminate some type assertions --- rate/ratelimit.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'rate') diff --git a/rate/ratelimit.go b/rate/ratelimit.go index 6645e04..f521f66 100644 --- a/rate/ratelimit.go +++ b/rate/ratelimit.go @@ -77,9 +77,9 @@ func (rl *Limiter) Allow() bool { } func (rl *Limiter) AllowN(n numTokens) bool { - return stm.Atomically(func(tx *stm.Tx) interface{} { + return stm.Atomically(func(tx *stm.Tx) bool { return rl.takeTokens(tx, n) - }).(bool) + }) } func (rl *Limiter) AllowStm(tx *stm.Tx) bool { @@ -105,7 +105,7 @@ func (rl *Limiter) Wait(ctx context.Context) error { func (rl *Limiter) WaitN(ctx context.Context, n int) error { ctxDone, cancel := stmutil.ContextDoneVar(ctx) defer cancel() - if err := stm.Atomically(func(tx *stm.Tx) interface{} { + if err := stm.Atomically(func(tx *stm.Tx) error { if ctxDone.Get(tx) { return ctx.Err() } @@ -123,7 +123,7 @@ func (rl *Limiter) WaitN(ctx context.Context, n int) error { tx.Retry() panic("unreachable") }); err != nil { - return err.(error) + return err } return nil -- cgit v1.2.3