Files
dolt/types/string.go
Rafael Weinstein d1e2aa01f3 Go: ref.Ref -> hash.Hash (#1583)
ref.Ref -> hash.Hash
2016-05-21 11:38:35 -07:00

48 lines
737 B
Go

package types
import "github.com/attic-labs/noms/hash"
type String struct {
s string
h *hash.Hash
}
func NewString(s string) String {
return String{s, &hash.Hash{}}
}
func (fs String) String() string {
return fs.s
}
// Value interface
func (s String) Equals(other Value) bool {
if other, ok := other.(String); ok {
return s.s == other.s
}
return false
}
func (s String) Less(other Value) bool {
if s2, ok := other.(String); ok {
return s.s < s2.s
}
return StringKind < other.Type().Kind()
}
func (fs String) Hash() hash.Hash {
return EnsureRef(fs.h, fs)
}
func (fs String) ChildValues() []Value {
return nil
}
func (fs String) Chunks() []Ref {
return nil
}
func (fs String) Type() *Type {
return StringType
}