From cd130ca7c8f3f770a5c2134097f71650c28a70a7 Mon Sep 17 00:00:00 2001 From: doug-q <141026920+doug-q@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:18:55 +0100 Subject: [PATCH] Update hugr/src/hugr/serialize.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Agustín Borgna <121866228+aborgna-q@users.noreply.github.com> --- hugr/src/hugr/serialize.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hugr/src/hugr/serialize.rs b/hugr/src/hugr/serialize.rs index 6532e1eb3..caba7c1a8 100644 --- a/hugr/src/hugr/serialize.rs +++ b/hugr/src/hugr/serialize.rs @@ -337,6 +337,12 @@ pub mod test { pub fn check_hugr_schema_roundtrip(hugr: &Hugr) -> Hugr { check_hugr_roundtrip(hugr, true) } + + /// Serialize and deserialize a HUGR, and check that the result is the same as the original. + /// + /// If `check_schema` is true, checks the serialized json against the in-tree schema. + /// + /// Returns the deserialized HUGR. pub fn check_hugr_roundtrip(hugr: &Hugr, check_schema: bool) -> Hugr { let new_hugr: Hugr = ser_roundtrip_validate(hugr, check_schema.then_some(&SCHEMA));