From 2d6d913213c947b07d3c22639593c04a67a53540 Mon Sep 17 00:00:00 2001 From: Kogia-sima Date: Wed, 16 Dec 2020 13:35:37 +0900 Subject: [PATCH] no longer requires `extern crate sailfish_macros` --- README.md | 4 ---- benches/src/sailfish.rs | 1 - docs/en/docs/getting-started.md | 3 --- docs/en/docs/installation.md | 8 -------- examples/actix.rs | 3 --- examples/include.rs | 3 --- examples/simple.rs | 3 --- sailfish-tests/integration-tests/Cargo.toml | 2 +- sailfish/src/lib.rs | 5 ++--- 9 files changed, 3 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 7dc9c0f..2803efd 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ Dependencies: ```toml [dependencies] sailfish = "0.2.3" -sailfish-macros = "0.2.3" ``` Template file (templates/hello.stpl): @@ -49,9 +48,6 @@ Template file (templates/hello.stpl): Code: ```rust -#[macro_use] -extern crate sailfish_macros; // enable derive macro - use sailfish::TemplateOnce; #[derive(TemplateOnce)] diff --git a/benches/src/sailfish.rs b/benches/src/sailfish.rs index 79e6ab0..366816f 100644 --- a/benches/src/sailfish.rs +++ b/benches/src/sailfish.rs @@ -1,5 +1,4 @@ use sailfish::TemplateOnce; -use sailfish_macros::TemplateOnce; pub fn big_table(b: &mut criterion::Bencher<'_>, size: &usize) { let mut table = Vec::with_capacity(*size); diff --git a/docs/en/docs/getting-started.md b/docs/en/docs/getting-started.md index b16cf83..a760956 100644 --- a/docs/en/docs/getting-started.md +++ b/docs/en/docs/getting-started.md @@ -29,9 +29,6 @@ templates/ Import the sailfish crates: ```rust -#[macro_use] -extern crate sailfish_macros; // enable derive macros - use sailfish::TemplateOnce; // import `TemplateOnce` trait ``` diff --git a/docs/en/docs/installation.md b/docs/en/docs/installation.md index cfda101..8ac9ffe 100644 --- a/docs/en/docs/installation.md +++ b/docs/en/docs/installation.md @@ -5,12 +5,4 @@ In order to use sailfish templates, you have add two dependencies in your `Cargo ```toml [dependencies] sailfish = "0.2.3" -sailfish-macros = "0.2.3" ``` - -`sailfish` crate contains runtime for rendering contents, and `sailfish-macros` serves you derive macros to compile and import the template files. - -These crates are separated so that Rust compiler can compile them independently. This separation makes your compilation faster! - -!!! Warning - Make sure that the `sailfish-macros` version is larger than `sailfish`, otherwise the compilation may fail. diff --git a/examples/actix.rs b/examples/actix.rs index 7666095..b5153fb 100644 --- a/examples/actix.rs +++ b/examples/actix.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate sailfish_macros; - use actix_web::error::InternalError; use actix_web::http::StatusCode; use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer}; diff --git a/examples/include.rs b/examples/include.rs index ae81efb..34db74e 100644 --- a/examples/include.rs +++ b/examples/include.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate sailfish_macros; - use sailfish::TemplateOnce; #[derive(TemplateOnce)] diff --git a/examples/simple.rs b/examples/simple.rs index 640b9ae..ed6b10b 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate sailfish_macros; - use sailfish::TemplateOnce; #[derive(TemplateOnce)] diff --git a/sailfish-tests/integration-tests/Cargo.toml b/sailfish-tests/integration-tests/Cargo.toml index 2354ab4..88b1301 100644 --- a/sailfish-tests/integration-tests/Cargo.toml +++ b/sailfish-tests/integration-tests/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" publish = false [dependencies] -sailfish = { path = "../../sailfish" } +sailfish = { path = "../../sailfish", default-features = false } sailfish-macros = { path = "../../sailfish-macros" } sailfish-compiler = { path = "../../sailfish-compiler" } diff --git a/sailfish/src/lib.rs b/sailfish/src/lib.rs index 895ded7..3e7fb69 100644 --- a/sailfish/src/lib.rs +++ b/sailfish/src/lib.rs @@ -11,9 +11,6 @@ //! `runtime::Render` trait for that type. //! //! ```ignore -//! #[macro_use] -//! extern crate sailfish_macros; -//! //! use sailfish::TemplateOnce; //! //! #[derive(TemplateOnce)] @@ -39,6 +36,8 @@ pub mod runtime; pub use runtime::{RenderError, RenderResult}; +#[cfg(feature = "derive")] +pub use sailfish_macros::TemplateOnce; /// Template that can be rendered with consuming itself. pub trait TemplateOnce: Sized {