From: Ian Jackson Date: Wed, 4 May 2022 19:47:12 +0000 (+0100) Subject: shapelib: Promote toplevel as table access X-Git-Tag: otter-1.1.0~281 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a40fedc3c8bf64d67adb13daf574c3d84ef186f1;p=otter.git shapelib: Promote toplevel as table access We're going to want to get more out of this. Signed-off-by: Ian Jackson --- diff --git a/src/shapelib.rs b/src/shapelib.rs index fdd83952..6b10f56b 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -758,6 +758,8 @@ impl LibrarySource for BuiltinLibrary<'_> { pub fn load_catalogue(libname: &str, src: &mut dyn LibrarySource) -> Catalogue { let toplevel: toml::Value = src.catalogue_data().parse()?; + let toplevel = toplevel + .as_table().ok_or_else(|| LLE::ExpectedTable(format!("toplevel")))?; let mut l = Catalogue { bundle: src.bundle(), libname: libname.to_string(), @@ -765,9 +767,7 @@ pub fn load_catalogue(libname: &str, src: &mut dyn LibrarySource) dirname: src.svg_dir(), }; let empty_table = toml::value::Value::Table(default()); - let groups = - toplevel - .as_table().ok_or_else(|| LLE::ExpectedTable(format!("toplevel")))? + let groups = toplevel .get("group").unwrap_or(&empty_table) .as_table().ok_or_else(|| LLE::ExpectedTable(format!("group")))?; for (groupname, gdefn) in groups {