File: cloner.go

package info (click to toggle)
golang-github-huandu-go-clone 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 685 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2023 Huan Du. All rights reserved.
// Licensed under the MIT license that can be found in the LICENSE file.

package clone

// Cloner implements clone API with given allocator.
type Cloner struct {
	allocator *Allocator
}

// MakeCloner creates a cloner with given allocator.
func MakeCloner(allocator *Allocator) Cloner {
	return Cloner{
		allocator: allocator,
	}
}

// Clone clones v with given allocator.
func (c Cloner) Clone(v interface{}) interface{} {
	return clone(c.allocator, v)
}

// CloneSlowly clones v with given allocator.
// It can clone v with cycle pointer.
func (c Cloner) CloneSlowly(v interface{}) interface{} {
	return cloneSlowly(c.allocator, v)
}