mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-26 11:35:35 +00:00
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
|
// 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"
|
||
|
)
|
||
|
|
||
|
// Clone makes a deep copy of SliceContianer.
|
||
|
// The result aliases no memory with the original.
|
||
|
func (src *SliceContianer) Clone() *SliceContianer {
|
||
|
if src == nil {
|
||
|
return nil
|
||
|
}
|
||
|
dst := new(SliceContianer)
|
||
|
*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.
|
||
|
var _SliceContianerCloneNeedsRegeneration = SliceContianer(struct {
|
||
|
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>,
|
||
|
// where T is one of SliceContianer.
|
||
|
func Clone(dst, src any) bool {
|
||
|
switch src := src.(type) {
|
||
|
case *SliceContianer:
|
||
|
switch dst := dst.(type) {
|
||
|
case *SliceContianer:
|
||
|
*dst = *src.Clone()
|
||
|
return true
|
||
|
case **SliceContianer:
|
||
|
*dst = src.Clone()
|
||
|
return true
|
||
|
}
|
||
|
}
|
||
|
return false
|
||
|
}
|