From a40fedc3c8bf64d67adb13daf574c3d84ef186f1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 4 May 2022 20:47:12 +0100 Subject: [PATCH] shapelib: Promote toplevel as table access We're going to want to get more out of this. Signed-off-by: Ian Jackson --- src/shapelib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 { -- 2.30.2