-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomparable.go
More file actions
37 lines (29 loc) · 786 Bytes
/
comparable.go
File metadata and controls
37 lines (29 loc) · 786 Bytes
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
package rad
import (
"bytes"
)
// Comparable defines an interface for art values
type Comparable interface {
// EqualTo returns true if the current value is equal to the provided value
EqualTo(v interface{}) bool
}
// Bytes defines a byteslice that satisfies the comparable interface
type Bytes []byte
// EqualTo returns true if the compared value is equal to the target value
func (b Bytes) EqualTo(v interface{}) bool {
cv, ok := v.(Bytes)
if !ok {
return false
}
return bytes.Equal(b, cv)
}
// String defines a string that satisfies the comparable interface
type String string
// EqualTo returns true if the compared value is equal to the target value
func (s String) EqualTo(v interface{}) bool {
cv, ok := v.(String)
if !ok {
return false
}
return s == cv
}