vRp.CD2g_test/utils/super/f.go

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)
}
}