v0.0.94
This commit is contained in:
@@ -60,3 +60,12 @@ func CoalesceStringer(s fmt.Stringer, def string) string {
|
||||
return s.String()
|
||||
}
|
||||
}
|
||||
|
||||
func SafeCast[T any](v any, def T) T {
|
||||
switch r := v.(type) {
|
||||
case T:
|
||||
return r
|
||||
default:
|
||||
return def
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user