2023-09-30 02:31:45 +01:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
|
|
|
// Code generated by tailscale.com/cmd/cloner; DO NOT EDIT.
|
|
|
|
|
|
|
|
package clonerex
|
|
|
|
|
|
|
|
import (
|
|
|
|
"tailscale.com/types/ptr"
|
|
|
|
)
|
|
|
|
|
2023-09-30 18:09:56 +01:00
|
|
|
// Clone makes a deep copy of SliceContainer.
|
2023-09-30 02:31:45 +01:00
|
|
|
// The result aliases no memory with the original.
|
2023-09-30 18:09:56 +01:00
|
|
|
func (src *SliceContainer) Clone() *SliceContainer {
|
2023-09-30 02:31:45 +01:00
|
|
|
if src == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2023-09-30 18:09:56 +01:00
|
|
|
dst := new(SliceContainer)
|
2023-09-30 02:31:45 +01:00
|
|
|
*dst = *src
|
|
|
|
if src.Slice != nil {
|
|
|
|
dst.Slice = make([]*int, len(src.Slice))
|
|
|
|
for i := range dst.Slice {
|
|
|
|
if src.Slice[i] == nil {
|
|
|
|
dst.Slice[i] = nil
|
|
|
|
} else {
|
|
|
|
dst.Slice[i] = ptr.To(*src.Slice[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dst
|
|
|
|
}
|
|
|
|
|
|
|
|
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
|
2023-09-30 18:09:56 +01:00
|
|
|
var _SliceContainerCloneNeedsRegeneration = SliceContainer(struct {
|
2023-09-30 02:31:45 +01:00
|
|
|
Slice []*int
|
|
|
|
}{})
|
|
|
|
|
|
|
|
// Clone duplicates src into dst and reports whether it succeeded.
|
|
|
|
// To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
|
2023-09-30 18:09:56 +01:00
|
|
|
// where T is one of SliceContainer.
|
2023-09-30 02:31:45 +01:00
|
|
|
func Clone(dst, src any) bool {
|
|
|
|
switch src := src.(type) {
|
2023-09-30 18:09:56 +01:00
|
|
|
case *SliceContainer:
|
2023-09-30 02:31:45 +01:00
|
|
|
switch dst := dst.(type) {
|
2023-09-30 18:09:56 +01:00
|
|
|
case *SliceContainer:
|
2023-09-30 02:31:45 +01:00
|
|
|
*dst = *src.Clone()
|
|
|
|
return true
|
2023-09-30 18:09:56 +01:00
|
|
|
case **SliceContainer:
|
2023-09-30 02:31:45 +01:00
|
|
|
*dst = src.Clone()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|