This commit is contained in:
withchao
2023-02-14 15:02:45 +08:00
parent 8435508f35
commit 1ae1f77a14
4 changed files with 108 additions and 177 deletions
+8
View File
@@ -425,3 +425,11 @@ func Unwrap(err error) error {
}
return err
}
// NotNilReplace 当new_不为空时, 将old设置为new_
func NotNilReplace[T any](old, new_ *T) {
if old == nil || new_ == nil {
return
}
*old = *new_
}