From 15d26befcca2460d9a006eb984057d17a2c38345 Mon Sep 17 00:00:00 2001 From: Mathieu David Date: Sun, 27 Mar 2016 18:22:17 +0200 Subject: [PATCH] Refactor: Move extern crate definitions to lib.rs --- src/book/bookconfig.rs | 3 +-- src/book/bookitem.rs | 4 +--- src/lib.rs | 7 +++++-- src/renderer/html_handlebars/hbs_renderer.rs | 7 ++----- src/renderer/html_handlebars/helpers/navigation.rs | 7 ++----- src/renderer/html_handlebars/helpers/playpen.rs | 2 -- src/renderer/html_handlebars/helpers/toc.rs | 10 +++------- src/utils/mod.rs | 5 +---- 8 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/book/bookconfig.rs b/src/book/bookconfig.rs index 5cc4b00e..e15f95cf 100644 --- a/src/book/bookconfig.rs +++ b/src/book/bookconfig.rs @@ -1,5 +1,4 @@ -extern crate rustc_serialize; -use self::rustc_serialize::json::Json; +use rustc_serialize::json::Json; use std::fs::File; use std::io::Read; use std::path::{Path, PathBuf}; diff --git a/src/book/bookitem.rs b/src/book/bookitem.rs index 7ab4a2a3..4dd98791 100644 --- a/src/book/bookitem.rs +++ b/src/book/bookitem.rs @@ -1,6 +1,4 @@ -extern crate rustc_serialize; - -use self::rustc_serialize::json::{Json, ToJson}; +use rustc_serialize::json::{Json, ToJson}; use std::path::PathBuf; use std::collections::BTreeMap; diff --git a/src/lib.rs b/src/lib.rs index 33010801..91aa9fa9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,8 +69,11 @@ //! //! Make sure to take a look at it. -#[macro_use] -pub mod macros; +extern crate rustc_serialize; +extern crate handlebars; +extern crate pulldown_cmark; + +#[macro_use] pub mod macros; pub mod book; mod parse; pub mod renderer; diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index ddcfcd25..ce6cf683 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -1,6 +1,3 @@ -extern crate handlebars; -extern crate rustc_serialize; - use renderer::html_handlebars::helpers; use renderer::Renderer; use book::MDBook; @@ -13,8 +10,8 @@ use std::error::Error; use std::io::{self, Read, Write}; use std::collections::BTreeMap; -use self::handlebars::{Handlebars, JsonRender}; -use self::rustc_serialize::json::{Json, ToJson}; +use handlebars::{Handlebars, JsonRender}; +use rustc_serialize::json::{Json, ToJson}; pub struct HtmlHandlebars; diff --git a/src/renderer/html_handlebars/helpers/navigation.rs b/src/renderer/html_handlebars/helpers/navigation.rs index c9e7a9ae..8b300a94 100644 --- a/src/renderer/html_handlebars/helpers/navigation.rs +++ b/src/renderer/html_handlebars/helpers/navigation.rs @@ -1,11 +1,8 @@ -extern crate handlebars; -extern crate rustc_serialize; - use std::path::Path; use std::collections::BTreeMap; -use self::rustc_serialize::json::{self, ToJson}; -use self::handlebars::{Handlebars, RenderError, RenderContext, Helper, Context, Renderable}; +use rustc_serialize::json::{self, ToJson}; +use handlebars::{Handlebars, RenderError, RenderContext, Helper, Context, Renderable}; // Handlebars helper for navigation diff --git a/src/renderer/html_handlebars/helpers/playpen.rs b/src/renderer/html_handlebars/helpers/playpen.rs index c17eb602..da04552b 100644 --- a/src/renderer/html_handlebars/helpers/playpen.rs +++ b/src/renderer/html_handlebars/helpers/playpen.rs @@ -1,5 +1,3 @@ -extern crate handlebars; - use std::path::{Path, PathBuf}; use std::fs::File; use std::io::Read; diff --git a/src/renderer/html_handlebars/helpers/toc.rs b/src/renderer/html_handlebars/helpers/toc.rs index ea56f5ed..9f4e142d 100644 --- a/src/renderer/html_handlebars/helpers/toc.rs +++ b/src/renderer/html_handlebars/helpers/toc.rs @@ -1,13 +1,9 @@ -extern crate handlebars; -extern crate rustc_serialize; -extern crate pulldown_cmark; - use std::path::Path; use std::collections::BTreeMap; -use self::rustc_serialize::json; -use self::handlebars::{Handlebars, HelperDef, RenderError, RenderContext, Helper, Context}; -use self::pulldown_cmark::{Parser, html, Event, Tag}; +use rustc_serialize::json; +use handlebars::{Handlebars, HelperDef, RenderError, RenderContext, Helper, Context}; +use pulldown_cmark::{Parser, html, Event, Tag}; // Handlebars helper to construct TOC #[derive(Clone, Copy)] diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 874896e2..59db1999 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,9 +1,6 @@ -extern crate pulldown_cmark; - pub mod fs; -use self::pulldown_cmark::{Parser, html, Options, OPTION_ENABLE_TABLES, OPTION_ENABLE_FOOTNOTES}; - +use pulldown_cmark::{Parser, html, Options, OPTION_ENABLE_TABLES, OPTION_ENABLE_FOOTNOTES}; ///