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