changed Object API
This commit is contained in:
parent
dcf2bac9b6
commit
fe99fddc29
2 changed files with 10 additions and 4 deletions
|
@ -128,12 +128,12 @@ fn obj(_: Vec<Value>) -> Value {
|
||||||
Value::Object(HashMap::new())
|
Value::Object(HashMap::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set(mut args: Vec<Value>) -> Value {
|
fn set(args: Vec<Value>) -> Value {
|
||||||
|
let mut object = args.get(0).unwrap().as_object().unwrap().clone();
|
||||||
let name = args.get(1).unwrap().as_string().unwrap().to_string();
|
let name = args.get(1).unwrap().as_string().unwrap().to_string();
|
||||||
let value = args.get(2).unwrap().clone();
|
let value = args.get(2).unwrap().clone();
|
||||||
let object = args.get_mut(0).unwrap().as_object_mut().unwrap();
|
object.insert(name, value);
|
||||||
object.insert(name, value.clone());
|
object.into()
|
||||||
value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get(args: Vec<Value>) -> Value {
|
fn get(args: Vec<Value>) -> Value {
|
||||||
|
|
|
@ -139,6 +139,12 @@ impl From<&str> for Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<HashMap<String, Value>> for Value {
|
||||||
|
fn from(value: HashMap<String, Value>) -> Self {
|
||||||
|
Self::Object(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> From<Option<T>> for Value
|
impl<T> From<Option<T>> for Value
|
||||||
where
|
where
|
||||||
T: Into<Value>,
|
T: Into<Value>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue