From f3332fb0da8eaa277d0d84ebc16a4b0de50eb7c8 Mon Sep 17 00:00:00 2001 From: klensy Date: Thu, 5 May 2022 09:33:51 +0300 Subject: [PATCH] Use serde's `derive` feature instead of directly importing serde_derive --- Cargo.lock | 4 +++- Cargo.toml | 3 +-- src/book/book.rs | 2 ++ src/book/summary.rs | 1 + src/lib.rs | 2 -- src/preprocess/mod.rs | 2 ++ src/renderer/html_handlebars/search.rs | 2 ++ src/renderer/mod.rs | 2 ++ 8 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9dae5361..f00d37f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -865,7 +865,6 @@ dependencies = [ "select", "semver", "serde", - "serde_derive", "serde_json", "shlex", "tempfile", @@ -1483,6 +1482,9 @@ name = "serde" version = "1.0.129" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d1f72836d2aa753853178eda473a3b9d8e4eefdaf20523b919677e6de489f8f1" +dependencies = [ + "serde_derive", +] [[package]] name = "serde_derive" diff --git a/Cargo.toml b/Cargo.toml index 6b2404fa..dc603aea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,7 @@ memchr = "2.0" opener = "0.5" pulldown-cmark = { version = "0.9.1", default-features = false } regex = "1.5.5" -serde = "1.0" -serde_derive = "1.0" +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" shlex = "1" tempfile = "3.0" diff --git a/src/book/book.rs b/src/book/book.rs index c3573d8c..d28c22da 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -9,6 +9,8 @@ use crate::config::BuildConfig; use crate::errors::*; use crate::utils::bracket_escape; +use serde::{Deserialize, Serialize}; + /// Load a book into memory from its `src/` directory. pub fn load_book>(src_dir: P, cfg: &BuildConfig) -> Result { let src_dir = src_dir.as_ref(); diff --git a/src/book/summary.rs b/src/book/summary.rs index 4bb8e969..2bd81580 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -1,6 +1,7 @@ use crate::errors::*; use memchr::{self, Memchr}; use pulldown_cmark::{self, Event, HeadingLevel, Tag}; +use serde::{Deserialize, Serialize}; use std::fmt::{self, Display, Formatter}; use std::iter::FromIterator; use std::ops::{Deref, DerefMut}; diff --git a/src/lib.rs b/src/lib.rs index 82d9b6f7..23309fb0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,8 +89,6 @@ extern crate lazy_static; #[macro_use] extern crate log; #[macro_use] -extern crate serde_derive; -#[macro_use] extern crate serde_json; #[cfg(test)] diff --git a/src/preprocess/mod.rs b/src/preprocess/mod.rs index ee660636..894e2003 100644 --- a/src/preprocess/mod.rs +++ b/src/preprocess/mod.rs @@ -16,6 +16,8 @@ use std::cell::RefCell; use std::collections::HashMap; use std::path::PathBuf; +use serde::{Deserialize, Serialize}; + /// Extra information for a `Preprocessor` to give them more context when /// processing a book. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] diff --git a/src/renderer/html_handlebars/search.rs b/src/renderer/html_handlebars/search.rs index 5dd063da..0a59ffe9 100644 --- a/src/renderer/html_handlebars/search.rs +++ b/src/renderer/html_handlebars/search.rs @@ -11,6 +11,8 @@ use crate::errors::*; use crate::theme::searcher; use crate::utils; +use serde::Serialize; + /// Creates all files required for search. pub fn create_files(search_config: &Search, destination: &Path, book: &Book) -> Result<()> { let mut index = Index::new(&["title", "body", "breadcrumbs"]); diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 9d2952c1..15465fbc 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -29,6 +29,8 @@ use crate::config::Config; use crate::errors::*; use toml::Value; +use serde::{Deserialize, Serialize}; + /// An arbitrary `mdbook` backend. /// /// Although it's quite possible for you to import `mdbook` as a library and