Files
vRp.CD2g_test/utils/super/f.go
kercylan98 ee87612f60 feat: 新增重试函数及两个关于 func 执行的辅助函数
支持通过 super.Handle 和 super.HandleV 对函数进行执行,如果传入的函数不为 nil 则会执行
2023-07-05 13:39:45 +08:00

24 lines
402 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package super
// Handle 执行 f 函数,如果 f 为 nil则不执行
func Handle(f func()) {
if f != nil {
f()
}
}
// HandleErr 执行 f 函数,如果 f 为 nil则不执行
func HandleErr(f func() error) error {
if f != nil {
return f()
}
return nil
}
// HandleV 执行 f 函数,如果 f 为 nil则不执行
func HandleV[V any](v V, f func(v V)) {
if f != nil {
f(v)
}
}