github.com/attic-labs/noms@v0.0.0-20210827224422-e5fa29d95e8b/go/types/bool.go (about) 1 // Copyright 2016 Attic Labs, Inc. All rights reserved. 2 // Licensed under the Apache License, version 2.0: 3 // http://www.apache.org/licenses/LICENSE-2.0 4 5 package types 6 7 import ( 8 "github.com/attic-labs/noms/go/hash" 9 ) 10 11 // Bool is a Noms Value wrapper around the primitive bool type. 12 type Bool bool 13 14 // Value interface 15 func (b Bool) Value() Value { 16 return b 17 } 18 19 func (b Bool) Equals(other Value) bool { 20 return b == other 21 } 22 23 func (b Bool) Less(other Value) bool { 24 if b2, ok := other.(Bool); ok { 25 return !bool(b) && bool(b2) 26 } 27 return true 28 } 29 30 func (b Bool) Hash() hash.Hash { 31 return getHash(b) 32 } 33 34 func (b Bool) WalkValues(cb ValueCallback) { 35 } 36 37 func (b Bool) WalkRefs(cb RefCallback) { 38 } 39 40 func (b Bool) typeOf() *Type { 41 return BoolType 42 } 43 44 func (b Bool) Kind() NomsKind { 45 return BoolKind 46 } 47 48 func (b Bool) valueReadWriter() ValueReadWriter { 49 return nil 50 } 51 52 func (b Bool) writeTo(w nomsWriter) { 53 BoolKind.writeTo(w) 54 w.writeBool(bool(b)) 55 } 56 57 func (b Bool) valueBytes() []byte { 58 if bool(b) { 59 return []byte{byte(BoolKind), 1} 60 } 61 return []byte{byte(BoolKind), 0} 62 }