From: Ian Jackson Date: Sun, 1 May 2022 17:20:02 +0000 (+0100) Subject: apitest: Introduce and use JsV extension set X-Git-Tag: otter-1.1.0~360 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=5739c746ad0657d5c490b42328d411ccdeb5975e;p=otter.git apitest: Introduce and use JsV extension set Signed-off-by: Ian Jackson --- diff --git a/apitest/apitest.rs b/apitest/apitest.rs index d2e051b9..d2a82358 100644 --- a/apitest/apitest.rs +++ b/apitest/apitest.rs @@ -128,6 +128,13 @@ impl From for E { fn from(e: Explode) -> E { match e { } } }*/ +#[ext(pub)] +impl JsV { + fn set>(&mut self, k: K, v: &JsV) { + self.as_object_mut().unwrap().insert(k.into(), v.clone()); + } +} + // -------------------- Substition -------------------- pub trait Substitutor { diff --git a/apitest/atmain.rs b/apitest/atmain.rs index 35cbd52e..ea5b155d 100644 --- a/apitest/atmain.rs +++ b/apitest/atmain.rs @@ -430,9 +430,7 @@ pub fn update_update_pieces( let d = d.as_object().unwrap(); p.pos = coord(&d["pos"]); for (k,v) in d { - p.info - .as_object_mut().unwrap() - .insert(k.to_string(), v.clone()); + p.info.set(k, &v); } }, _ => {