From 0b897ce7c728e9c520a3ff56ba7deba94c1e2f4c Mon Sep 17 00:00:00 2001 From: Peng Guanwen Date: Tue, 29 Jan 2019 16:30:54 +0800 Subject: [PATCH] Replace trim_{left, right} with trim_{start, end} trim_{start, end} is introduced in rust 1.30.0 and trim_{left, right} is deprecated since 1.33.0. --- components/library/src/content/page.rs | 2 +- components/rendering/src/shortcode.rs | 2 +- components/templates/src/filters.rs | 4 ++-- src/cmd/init.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/library/src/content/page.rs b/components/library/src/content/page.rs index cc5407c9..89796d49 100644 --- a/components/library/src/content/page.rs +++ b/components/library/src/content/page.rs @@ -153,7 +153,7 @@ impl Page { }; if let Some(ref p) = page.meta.path { - page.path = p.trim().trim_left_matches('/').to_string(); + page.path = p.trim().trim_start_matches('/').to_string(); } else { let mut path = if page.file.components.is_empty() { page.slug.clone() diff --git a/components/rendering/src/shortcode.rs b/components/rendering/src/shortcode.rs index 26450842..e5bd6795 100644 --- a/components/rendering/src/shortcode.rs +++ b/components/rendering/src/shortcode.rs @@ -108,7 +108,7 @@ fn render_shortcode( } if let Some(ref b) = body { // Trimming right to avoid most shortcodes with bodies ending up with a HTML new line - tera_context.insert("body", b.trim_right()); + tera_context.insert("body", b.trim_end()); } tera_context.extend(context.tera_context.clone()); diff --git a/components/templates/src/filters.rs b/components/templates/src/filters.rs index a8911afa..133feb87 100644 --- a/components/templates/src/filters.rs +++ b/components/templates/src/filters.rs @@ -21,9 +21,9 @@ pub fn markdown(value: &Value, args: &HashMap) -> TeraResult") + .trim_start_matches("

") // pulldown_cmark finishes a paragraph with `

\n` - .trim_right_matches("

\n") + .trim_end_matches("

\n") .to_string(); } diff --git a/src/cmd/init.rs b/src/cmd/init.rs index c47ef5d3..b2634821 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -41,7 +41,7 @@ pub fn create_new_project(name: &str) -> Result<()> { let search = ask_bool("> Do you want to build a search index of the content?", false)?; let config = CONFIG - .trim_left() + .trim_start() .replace("%BASE_URL%", &base_url) .replace("%COMPILE_SASS%", &format!("{}", compile_sass)) .replace("%SEARCH%", &format!("{}", search))