@@ -103,6 +103,11 @@ impl From<i64> for Value {
103103 Value :: I64 ( from)
104104 }
105105}
106+ impl From < u64 > for Value {
107+ fn from ( from : u64 ) -> Value {
108+ Value :: U64 ( from)
109+ }
110+ }
106111impl From < f64 > for Value {
107112 fn from ( from : f64 ) -> Value {
108113 Value :: F64 ( from)
@@ -113,8 +118,15 @@ impl From<String> for Value {
113118 Value :: Str ( from)
114119 }
115120}
121+
122+ impl < T : Into < Value > > From < Option < T > > for Value {
123+ fn from ( from : Option < T > ) -> Value {
124+ from. map ( |v| v. into ( ) ) . unwrap_or ( Value :: Null )
125+ }
126+ }
127+
116128impl From < Value > for String {
117- // unsafe
129+ // assumes all can be cast to string
118130 fn from ( from : Value ) -> String {
119131 from. cast ( ) . unwrap ( )
120132 }
@@ -124,6 +136,7 @@ impl PartialEq for Value {
124136 fn eq ( & self , other : & Value ) -> bool {
125137 match ( self , other) {
126138 ( Value :: Bool ( l) , Value :: Bool ( r) ) => l == r,
139+ ( Value :: U64 ( l) , Value :: U64 ( r) ) => l == r,
127140 ( Value :: I64 ( l) , Value :: I64 ( r) ) => l == r,
128141 ( Value :: F64 ( l) , Value :: F64 ( r) ) => l == r,
129142 ( Value :: Str ( l) , Value :: Str ( r) ) => l == r,
0 commit comments