From 53ba0d6655939358755daf980f9ffbd728f0fa49 Mon Sep 17 00:00:00 2001 From: lzutao Date: Fri, 31 May 2019 23:01:02 +0700 Subject: [PATCH] Remove 'static lifetime from static vars (#947) --- src/book/mod.rs | 4 +- .../html_handlebars/helpers/navigation.rs | 2 +- src/theme/mod.rs | 44 +++++++++---------- src/theme/playpen_editor/mod.rs | 10 ++--- src/theme/searcher/mod.rs | 6 +-- tests/init.rs | 2 +- 6 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/book/mod.rs b/src/book/mod.rs index 5453a2b4..c8a7bfce 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -525,7 +525,7 @@ mod tests { #[test] fn can_determine_third_party_preprocessors() { - let cfg_str: &'static str = r#" + let cfg_str = r#" [book] title = "Some Book" @@ -564,7 +564,7 @@ mod tests { #[test] fn config_respects_preprocessor_selection() { - let cfg_str: &'static str = r#" + let cfg_str = r#" [preprocessor.links] renderers = ["html"] "#; diff --git a/src/renderer/html_handlebars/helpers/navigation.rs b/src/renderer/html_handlebars/helpers/navigation.rs index 9264d598..4d162af7 100644 --- a/src/renderer/html_handlebars/helpers/navigation.rs +++ b/src/renderer/html_handlebars/helpers/navigation.rs @@ -171,7 +171,7 @@ pub fn next( mod tests { use super::*; - static TEMPLATE: &'static str = + static TEMPLATE: &str = "{{#previous}}{{title}}: {{link}}{{/previous}}|{{#next}}{{title}}: {{link}}{{/next}}"; #[test] diff --git a/src/theme/mod.rs b/src/theme/mod.rs index 3598322a..aab96db7 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -11,31 +11,27 @@ use std::path::Path; use crate::errors::*; -pub static INDEX: &'static [u8] = include_bytes!("index.hbs"); -pub static HEADER: &'static [u8] = include_bytes!("header.hbs"); -pub static CHROME_CSS: &'static [u8] = include_bytes!("css/chrome.css"); -pub static GENERAL_CSS: &'static [u8] = include_bytes!("css/general.css"); -pub static PRINT_CSS: &'static [u8] = include_bytes!("css/print.css"); -pub static VARIABLES_CSS: &'static [u8] = include_bytes!("css/variables.css"); -pub static FAVICON: &'static [u8] = include_bytes!("favicon.png"); -pub static JS: &'static [u8] = include_bytes!("book.js"); -pub static HIGHLIGHT_JS: &'static [u8] = include_bytes!("highlight.js"); -pub static TOMORROW_NIGHT_CSS: &'static [u8] = include_bytes!("tomorrow-night.css"); -pub static HIGHLIGHT_CSS: &'static [u8] = include_bytes!("highlight.css"); -pub static AYU_HIGHLIGHT_CSS: &'static [u8] = include_bytes!("ayu-highlight.css"); -pub static CLIPBOARD_JS: &'static [u8] = include_bytes!("clipboard.min.js"); -pub static FONT_AWESOME: &'static [u8] = include_bytes!("FontAwesome/css/font-awesome.min.css"); -pub static FONT_AWESOME_EOT: &'static [u8] = - include_bytes!("FontAwesome/fonts/fontawesome-webfont.eot"); -pub static FONT_AWESOME_SVG: &'static [u8] = - include_bytes!("FontAwesome/fonts/fontawesome-webfont.svg"); -pub static FONT_AWESOME_TTF: &'static [u8] = - include_bytes!("FontAwesome/fonts/fontawesome-webfont.ttf"); -pub static FONT_AWESOME_WOFF: &'static [u8] = - include_bytes!("FontAwesome/fonts/fontawesome-webfont.woff"); -pub static FONT_AWESOME_WOFF2: &'static [u8] = +pub static INDEX: &[u8] = include_bytes!("index.hbs"); +pub static HEADER: &[u8] = include_bytes!("header.hbs"); +pub static CHROME_CSS: &[u8] = include_bytes!("css/chrome.css"); +pub static GENERAL_CSS: &[u8] = include_bytes!("css/general.css"); +pub static PRINT_CSS: &[u8] = include_bytes!("css/print.css"); +pub static VARIABLES_CSS: &[u8] = include_bytes!("css/variables.css"); +pub static FAVICON: &[u8] = include_bytes!("favicon.png"); +pub static JS: &[u8] = include_bytes!("book.js"); +pub static HIGHLIGHT_JS: &[u8] = include_bytes!("highlight.js"); +pub static TOMORROW_NIGHT_CSS: &[u8] = include_bytes!("tomorrow-night.css"); +pub static HIGHLIGHT_CSS: &[u8] = include_bytes!("highlight.css"); +pub static AYU_HIGHLIGHT_CSS: &[u8] = include_bytes!("ayu-highlight.css"); +pub static CLIPBOARD_JS: &[u8] = include_bytes!("clipboard.min.js"); +pub static FONT_AWESOME: &[u8] = include_bytes!("FontAwesome/css/font-awesome.min.css"); +pub static FONT_AWESOME_EOT: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.eot"); +pub static FONT_AWESOME_SVG: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.svg"); +pub static FONT_AWESOME_TTF: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.ttf"); +pub static FONT_AWESOME_WOFF: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.woff"); +pub static FONT_AWESOME_WOFF2: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.woff2"); -pub static FONT_AWESOME_OTF: &'static [u8] = include_bytes!("FontAwesome/fonts/FontAwesome.otf"); +pub static FONT_AWESOME_OTF: &[u8] = include_bytes!("FontAwesome/fonts/FontAwesome.otf"); /// The `Theme` struct should be used instead of the static variables because /// the `new()` method will look if the user has a theme directory in their diff --git a/src/theme/playpen_editor/mod.rs b/src/theme/playpen_editor/mod.rs index 447e81ed..0fdf7132 100644 --- a/src/theme/playpen_editor/mod.rs +++ b/src/theme/playpen_editor/mod.rs @@ -1,7 +1,7 @@ //! Theme dependencies for the playpen editor. -pub static JS: &'static [u8] = include_bytes!("editor.js"); -pub static ACE_JS: &'static [u8] = include_bytes!("ace.js"); -pub static MODE_RUST_JS: &'static [u8] = include_bytes!("mode-rust.js"); -pub static THEME_DAWN_JS: &'static [u8] = include_bytes!("theme-dawn.js"); -pub static THEME_TOMORROW_NIGHT_JS: &'static [u8] = include_bytes!("theme-tomorrow_night.js"); +pub static JS: &[u8] = include_bytes!("editor.js"); +pub static ACE_JS: &[u8] = include_bytes!("ace.js"); +pub static MODE_RUST_JS: &[u8] = include_bytes!("mode-rust.js"); +pub static THEME_DAWN_JS: &[u8] = include_bytes!("theme-dawn.js"); +pub static THEME_TOMORROW_NIGHT_JS: &[u8] = include_bytes!("theme-tomorrow_night.js"); diff --git a/src/theme/searcher/mod.rs b/src/theme/searcher/mod.rs index c80441d0..d5029db1 100644 --- a/src/theme/searcher/mod.rs +++ b/src/theme/searcher/mod.rs @@ -1,6 +1,6 @@ //! Theme dependencies for in-browser search. Not included in mdbook when //! the "search" cargo feature is disabled. -pub static JS: &'static [u8] = include_bytes!("searcher.js"); -pub static MARK_JS: &'static [u8] = include_bytes!("mark.min.js"); -pub static ELASTICLUNR_JS: &'static [u8] = include_bytes!("elasticlunr.min.js"); +pub static JS: &[u8] = include_bytes!("searcher.js"); +pub static MARK_JS: &[u8] = include_bytes!("mark.min.js"); +pub static ELASTICLUNR_JS: &[u8] = include_bytes!("elasticlunr.min.js"); diff --git a/tests/init.rs b/tests/init.rs index d54e4fb1..248cb623 100644 --- a/tests/init.rs +++ b/tests/init.rs @@ -35,7 +35,7 @@ fn run_mdbook_init_should_create_content_from_summary() { let temp = TempFileBuilder::new().prefix("mdbook").tempdir().unwrap(); let src_dir = temp.path().join("src"); fs::create_dir_all(src_dir.clone()).unwrap(); - static SUMMARY: &'static str = r#"# Summary + static SUMMARY: &str = r#"# Summary [intro](intro.md)