-
Notifications
You must be signed in to change notification settings - Fork 0
/
clone.go
90 lines (68 loc) · 1.23 KB
/
clone.go
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package gost
import "reflect"
// A common trait for the ability to explicitly duplicate an object.
type Clone[T any] interface {
Clone() T
}
func castToClone[T any](value T) _InternalOption[Clone[T]] {
reflectedValue := reflect.ValueOf(value)
if casted, ok := reflectedValue.Interface().(Clone[T]); ok {
return _Some[Clone[T]](casted)
} else {
return _None[Clone[T]]()
}
}
func (self ISize) Clone() ISize {
return self
}
func (self I8) Clone() I8 {
return self
}
func (self I16) Clone() I16 {
return self
}
func (self I32) Clone() I32 {
return self
}
func (self I64) Clone() I64 {
return self
}
func (self USize) Clone() USize {
return self
}
func (self U8) Clone() U8 {
return self
}
func (self U16) Clone() U16 {
return self
}
func (self U32) Clone() U32 {
return self
}
func (self U64) Clone() U64 {
return self
}
func (self F32) Clone() F32 {
return self
}
func (self F64) Clone() F64 {
return self
}
func (self Byte) Clone() Byte {
return self
}
func (self Char) Clone() Char {
return self
}
func (self String) Clone() String {
return self
}
func (self Bool) Clone() Bool {
return self
}
func (self Complex64) Clone() Complex64 {
return self
}
func (self Complex128) Clone() Complex128 {
return self
}