From b80c1939d412eaec1f354562e3054d244ed7848c Mon Sep 17 00:00:00 2001 From: Yong Wen Chua Date: Wed, 31 Oct 2018 10:59:01 +0800 Subject: [PATCH] Remove `macro_use` on `extern crate` (#47) * Remove macro_use from examples * Remove macro_use from log and rocket * Remove macro_use for serde_derive * Remove from examples * Fix no-default features build failure --- examples/fairing.rs | 2 +- examples/guard.rs | 2 +- examples/manual.rs | 3 +-- examples/mix.rs | 2 +- src/fairing.rs | 3 ++- src/headers.rs | 2 ++ src/lib.rs | 25 ++++++++++++++----------- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/examples/fairing.rs b/examples/fairing.rs index 80f8c52..88a4b7e 100644 --- a/examples/fairing.rs +++ b/examples/fairing.rs @@ -1,9 +1,9 @@ #![feature(proc_macro_hygiene, decl_macro)] -#[macro_use] extern crate rocket; extern crate rocket_cors; use rocket::http::Method; +use rocket::{get, routes}; use rocket_cors::{AllowedHeaders, AllowedOrigins}; #[get("/")] diff --git a/examples/guard.rs b/examples/guard.rs index 4c9f7c0..ab087c8 100644 --- a/examples/guard.rs +++ b/examples/guard.rs @@ -1,5 +1,4 @@ #![feature(proc_macro_hygiene, decl_macro)] -#[macro_use] extern crate rocket; extern crate rocket_cors; @@ -7,6 +6,7 @@ use std::io::Cursor; use rocket::http::Method; use rocket::Response; +use rocket::{get, options, routes}; use rocket_cors::{AllowedHeaders, AllowedOrigins, Guard, Responder}; /// Using a `Responder` -- the usual way you would use this diff --git a/examples/manual.rs b/examples/manual.rs index 60a1a13..bc0b4de 100644 --- a/examples/manual.rs +++ b/examples/manual.rs @@ -1,5 +1,4 @@ #![feature(proc_macro_hygiene, decl_macro)] -#[macro_use] extern crate rocket; extern crate rocket_cors; @@ -7,7 +6,7 @@ use std::io::Cursor; use rocket::http::Method; use rocket::response::Responder; -use rocket::{Response, State}; +use rocket::{get, options, routes, Response, State}; use rocket_cors::{AllowedHeaders, AllowedOrigins, Cors}; /// Using a borrowed Cors diff --git a/examples/mix.rs b/examples/mix.rs index ad88e8b..f2fd0dd 100644 --- a/examples/mix.rs +++ b/examples/mix.rs @@ -4,12 +4,12 @@ //! `ping` route that you want to allow all Origins to access. #![feature(proc_macro_hygiene, decl_macro)] -#[macro_use] extern crate rocket; extern crate rocket_cors; use rocket::http::Method; use rocket::response::Responder; +use rocket::{get, options, routes}; use rocket_cors::{AllowedHeaders, AllowedOrigins, Cors, Guard}; /// The "usual" app route diff --git a/src/fairing.rs b/src/fairing.rs index ebebcdb..c33dd6b 100644 --- a/src/fairing.rs +++ b/src/fairing.rs @@ -1,8 +1,9 @@ //! Fairing implementation use std::str::FromStr; +use log::{error, info, log}; use rocket::http::{self, uri::Origin, Header, Status}; -use rocket::{self, Outcome, Request}; +use rocket::{self, error_, info_, log_, Outcome, Request}; use crate::{ actual_request_response, origin, preflight_response, request_headers, validate, Cors, Error, diff --git a/src/headers.rs b/src/headers.rs index 3792bba..300c73f 100644 --- a/src/headers.rs +++ b/src/headers.rs @@ -8,6 +8,8 @@ use std::str::FromStr; use rocket::http::Status; use rocket::request::{self, FromRequest}; use rocket::{self, Outcome}; +#[cfg(feature = "serialization")] +use serde_derive::{Deserialize, Serialize}; use unicase::UniCase; use url; diff --git a/src/lib.rs b/src/lib.rs index da46507..cad1949 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,9 +102,10 @@ //! //! ```rust,no_run //! #![feature(proc_macro_hygiene, decl_macro)] -//! #[macro_use] extern crate rocket; +//! extern crate rocket; //! extern crate rocket_cors; //! +//! use rocket::{get, routes}; //! use rocket::http::Method; //! use rocket_cors::{AllowedOrigins, AllowedHeaders}; //! @@ -176,12 +177,12 @@ //! //! ```rust,no_run //! #![feature(proc_macro_hygiene, decl_macro)] -//! #[macro_use] extern crate rocket; +//! extern crate rocket; //! extern crate rocket_cors; //! //! use std::io::Cursor; //! -//! use rocket::Response; +//! use rocket::{Response, get, options, routes}; //! use rocket::http::Method; //! use rocket_cors::{Guard, AllowedOrigins, AllowedHeaders, Responder}; //! @@ -294,9 +295,10 @@ //! //! ```rust,no_run //! #![feature(proc_macro_hygiene, decl_macro)] -//! #[macro_use] extern crate rocket; +//! extern crate rocket; //! extern crate rocket_cors; //! +//! use rocket::{get, options, routes}; //! use rocket::http::Method; //! use rocket::response::Responder; //! use rocket_cors::{Cors, AllowedOrigins, AllowedHeaders}; @@ -350,12 +352,12 @@ //! //! ```rust,no_run //! #![feature(proc_macro_hygiene, decl_macro)] -//! #[macro_use] extern crate rocket; +//! extern crate rocket; //! extern crate rocket_cors; //! //! use std::io::Cursor; //! -//! use rocket::{State, Response}; +//! use rocket::{State, Response, get, routes}; //! use rocket::http::Method; //! use rocket::response::Responder; //! use rocket_cors::{Cors, AllowedOrigins, AllowedHeaders}; @@ -418,9 +420,10 @@ //! //! ```rust,no_run //! #![feature(proc_macro_hygiene, decl_macro)] -//! #[macro_use] extern crate rocket; +//! extern crate rocket; //! extern crate rocket_cors; //! +//! use rocket::{get, options, routes}; //! use rocket::http::Method; //! use rocket::response::Responder; //! use rocket_cors::{Cors, Guard, AllowedOrigins, AllowedHeaders}; @@ -545,9 +548,7 @@ )] #![doc(test(attr(allow(unused_variables), deny(warnings))))] -#[macro_use] extern crate log; -#[macro_use] extern crate rocket; extern crate unicase; extern crate url; @@ -555,7 +556,6 @@ extern crate url; #[cfg(feature = "serialization")] extern crate serde; #[cfg(feature = "serialization")] -#[macro_use] extern crate serde_derive; #[cfg(feature = "serialization")] extern crate unicase_serde; @@ -586,10 +586,13 @@ use std::marker::PhantomData; use std::ops::Deref; use std::str::FromStr; +use log::{error, info, log}; use rocket::http::{self, Status}; use rocket::request::{FromRequest, Request}; use rocket::response; -use rocket::{Outcome, State}; +use rocket::{error_, info_, log_, Outcome, State}; +#[cfg(feature = "serialization")] +use serde_derive::{Deserialize, Serialize}; use crate::headers::{ AccessControlRequestHeaders, AccessControlRequestMethod, HeaderFieldName, HeaderFieldNamesSet,