Remove the Foo/flatFoo abstraction in the types package.

Fixes #24.
This commit is contained in:
Aaron Boodman
2015-07-10 11:29:03 -07:00
parent 82a87d548c
commit 96f21c4a60
11 changed files with 338 additions and 404 deletions
+27 -7
View File
@@ -1,14 +1,34 @@
package types
type String interface {
Value
import (
"github.com/attic-labs/noms/ref"
)
Blob() Blob
// Slurps the entire string into memory. You obviously don't want to do this if the string might be large.
String() string
type String struct {
s string
cr *cachedRef
}
func NewString(s string) String {
return flatString{s, &cachedRef{}}
return String{s, &cachedRef{}}
}
func (fs String) Blob() Blob {
return NewBlob([]byte(fs.s))
}
func (fs String) String() string {
return fs.s
}
func (fs String) Ref() ref.Ref {
return fs.cr.Ref(fs)
}
func (fs String) Equals(other Value) bool {
if other == nil {
return false
} else {
return fs.Ref() == other.Ref()
}
}