You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
247 B

2 years ago
2 years ago
  1. package gentools
  2. func Ptr[T any](t T) *T {
  3. return &t
  4. }
  5. func ShallowCopy[T any](t *T) *T {
  6. if t == nil {
  7. return t
  8. }
  9. tCopy := *t
  10. return &tCopy
  11. }
  12. func ShallowCopyTo[T any](dst **T, src *T) {
  13. if src != nil {
  14. *dst = ShallowCopy(src)
  15. }
  16. }