From 335b388aad0baec9087531f68a86f8b9906d0447 Mon Sep 17 00:00:00 2001 From: KmolYuan Date: Mon, 26 Jul 2021 15:00:10 +0800 Subject: [PATCH] Update YAML API. --- Cargo.toml | 2 +- src/loader/content.rs | 5 ++--- src/loader/mod.rs | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8476d36..6df22cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,5 +21,5 @@ zip = "0.5" reqwest = { version = "0.11", features = ["blocking"] } actix-web = "3.3" actix-files = "0.5" -yaml-peg = "0.10" +yaml-peg = "0.12" pulldown-cmark = "0.8" diff --git a/src/loader/content.rs b/src/loader/content.rs index 27b8990..dab9055 100644 --- a/src/loader/content.rs +++ b/src/loader/content.rs @@ -58,7 +58,7 @@ struct FragMap(HashMap>); impl FragMap { fn new(slide: &Node, count: &mut usize) -> Result { let mut frag_map = HashMap::new(); - for h in slide.get_default("fragment", &vec![], Node::as_array)? { + for h in slide.get_default("fragment", vec![], Node::as_array)? { for (k, v) in h.as_map()?.iter() { let k = k.as_str()?; let v = v.as_str()?; @@ -177,8 +177,7 @@ pub(crate) fn content_block( .iter() .enumerate() { - let empty = vec![]; - let stack = slide.get_default(title, &empty, Node::as_array)?; + let stack = slide.get_default(title, vec![], Node::as_array)?; if stack.is_empty() { continue; } diff --git a/src/loader/mod.rs b/src/loader/mod.rs index 8c7f8cb..a59dcc9 100644 --- a/src/loader/mod.rs +++ b/src/loader/mod.rs @@ -203,7 +203,7 @@ fn load_main(yaml: Array, v: &Anchors, mount: &str) -> Result, v: &Anchors, mount: &str) -> Result{}", i, t); - let empty = vec![]; - let sub = slide.get_default("sub", &empty, Node::as_array)?; + let sub = slide.get_default("sub", vec![], Node::as_array)?; if sub.is_empty() { continue; }