From 5739c746ad0657d5c490b42328d411ccdeb5975e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 1 May 2022 18:20:02 +0100 Subject: [PATCH] apitest: Introduce and use JsV extension set Signed-off-by: Ian Jackson --- apitest/apitest.rs | 7 +++++++ apitest/atmain.rs | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) 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); } }, _ => { -- 2.30.2