tools avoid unnecessary copying of parameters/properties
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
a4ba60be8f
commit
3530430365
@ -142,16 +142,16 @@ pub fn required_integer_property(param: &Value, name: &str) -> Result<i64, Error
|
||||
}
|
||||
}
|
||||
|
||||
pub fn required_array_param(param: &Value, name: &str) -> Result<Vec<Value>, Error> {
|
||||
pub fn required_array_param<'a>(param: &'a Value, name: &str) -> Result<&'a [Value], Error> {
|
||||
match param[name].as_array() {
|
||||
Some(s) => Ok(s.to_vec()),
|
||||
Some(s) => Ok(&s),
|
||||
None => bail!("missing parameter '{}'", name),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn required_array_property(param: &Value, name: &str) -> Result<Vec<Value>, Error> {
|
||||
pub fn required_array_property<'a>(param: &'a Value, name: &str) -> Result<&'a [Value], Error> {
|
||||
match param[name].as_array() {
|
||||
Some(s) => Ok(s.to_vec()),
|
||||
Some(s) => Ok(&s),
|
||||
None => bail!("missing property '{}'", name),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user