From f4f80b20e29d67ed88dea0faf91c6c100fbc8371 Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Tue, 27 Apr 2021 19:01:31 +0300 Subject: [PATCH] transition paths to 2018 edition Replaces all `extern crate ...` and especially #[macro_use] statements with direct `use`s of relevant items. Introduces cstr! crate & macro to examples, because we don't want our dear users/readers to suffer with raw CStr nightmare: std::ffi::CStr::from_bytes_with_nul(b"...\0").unwrap() --- README.md | 6 ++---- examples/graph/build.rs | 1 - examples/qmlextensionplugins/Cargo.toml | 1 + examples/qmlextensionplugins/src/lib.rs | 19 ++++++++----------- examples/todos/Cargo.toml | 1 + examples/todos/src/implementation.rs | 3 ++- examples/todos/src/main.rs | 12 +++--------- examples/webengine/src/main.rs | 1 - qmetaobject/src/connections.rs | 4 +++- qmetaobject/src/future.rs | 2 ++ qmetaobject/src/itemmodel.rs | 2 ++ qmetaobject/src/lib.rs | 11 ++++------- qmetaobject/src/listmodel.rs | 5 ++++- qmetaobject/src/log.rs | 2 ++ qmetaobject/src/qmetatype.rs | 2 ++ qmetaobject/src/qrc.rs | 1 + qmetaobject/src/qtdeclarative.rs | 2 ++ qmetaobject/src/scenegraph.rs | 3 +-- qmetaobject/src/tablemodel.rs | 5 ++++- qmetaobject/src/webengine.rs | 2 ++ qmetaobject/tests/common/mod.rs | 3 ++- qmetaobject/tests/models.rs | 8 +++----- qmetaobject/tests/tests.rs | 8 ++------ qmetaobject_impl/src/lib.rs | 11 +++-------- qmetaobject_impl/src/qbjs.rs | 1 - qmetaobject_impl/src/qobject_impl.rs | 14 ++++++++------ qmetaobject_impl/src/qrc_impl.rs | 5 +++-- qmetaobject_impl/src/simplelistitem_impl.rs | 5 +++-- 28 files changed, 70 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 94b345a3..5294f387 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,11 @@ Presentation Blog Post: https://woboq.com/blog/qmetaobject-from-rust.html ## Overview ```rust -#[macro_use] extern crate cstr; -extern crate qmetaobject; - +use cstr::cstr; use qmetaobject::*; // The `QObject` custom derive macro allows to expose a class to Qt and QML -#[derive(QObject,Default)] +#[derive(QObject, Default)] struct Greeter { // Specify the base class with the qt_base_class macro base: qt_base_class!(trait QObject), diff --git a/examples/graph/build.rs b/examples/graph/build.rs index dfa24caf..7e265e3d 100644 --- a/examples/graph/build.rs +++ b/examples/graph/build.rs @@ -15,7 +15,6 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -extern crate cpp_build; fn main() { let qt_include_path = std::env::var("DEP_QT_INCLUDE_PATH").unwrap(); diff --git a/examples/qmlextensionplugins/Cargo.toml b/examples/qmlextensionplugins/Cargo.toml index a03c71e4..30f4d68b 100644 --- a/examples/qmlextensionplugins/Cargo.toml +++ b/examples/qmlextensionplugins/Cargo.toml @@ -11,3 +11,4 @@ crate-type = ["cdylib"] [dependencies] qmetaobject = { path = "../../qmetaobject"} chrono = "^0.4" +cstr = "0.2" diff --git a/examples/qmlextensionplugins/src/lib.rs b/examples/qmlextensionplugins/src/lib.rs index c4d6f33a..e42ef5b9 100644 --- a/examples/qmlextensionplugins/src/lib.rs +++ b/examples/qmlextensionplugins/src/lib.rs @@ -1,10 +1,12 @@ -extern crate qmetaobject; -use qmetaobject::*; -extern crate chrono; -use chrono::Timelike; +use std::ffi::CStr; use std::sync::{Arc, Condvar, Mutex}; use std::thread::JoinHandle; +use chrono::Timelike; +use cstr::cstr; + +use qmetaobject::*; + #[derive(Default)] struct AbortCondVar { is_aborted: Mutex, @@ -75,13 +77,8 @@ struct QExampleQmlPlugin { } impl QQmlExtensionPlugin for QExampleQmlPlugin { - fn register_types(&mut self, uri: &std::ffi::CStr) { + fn register_types(&mut self, uri: &CStr) { //assert_eq!(uri, std::ffi::CStr::from_bytes_with_nul(b"TimeExample\0")); - qml_register_type::( - uri, - 1, - 0, - std::ffi::CStr::from_bytes_with_nul(b"Time\0").unwrap(), - ); + qml_register_type::(uri, 1, 0, cstr!("Time")); } } diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml index d7992108..ad213258 100644 --- a/examples/todos/Cargo.toml +++ b/examples/todos/Cargo.toml @@ -6,3 +6,4 @@ authors = ["Olivier Goffart "] [dependencies] qmetaobject = { path = "../../qmetaobject"} +cstr = "0.2" diff --git a/examples/todos/src/implementation.rs b/examples/todos/src/implementation.rs index e017fa18..6af70933 100644 --- a/examples/todos/src/implementation.rs +++ b/examples/todos/src/implementation.rs @@ -18,9 +18,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -use qmetaobject::*; use std::collections::HashMap; +use qmetaobject::*; + #[derive(Default, Clone)] struct TodosItem { completed: bool, diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index c7fa32b8..1de20310 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -1,7 +1,6 @@ -extern crate qmetaobject; -use qmetaobject::*; +use cstr::cstr; -use std::ffi::CStr; +use qmetaobject::*; mod implementation; @@ -13,12 +12,7 @@ qrc!(my_resource, fn main() { my_resource(); - qml_register_type::( - CStr::from_bytes_with_nul(b"RustCode\0").unwrap(), - 1, - 0, - CStr::from_bytes_with_nul(b"Todos\0").unwrap(), - ); + qml_register_type::(cstr!("RustCode"), 1, 0, cstr!("Todos")); let mut engine = QmlEngine::new(); engine.load_file("qrc:/todos/qml/main.qml".into()); engine.exec(); diff --git a/examples/webengine/src/main.rs b/examples/webengine/src/main.rs index e897a98e..887cb501 100644 --- a/examples/webengine/src/main.rs +++ b/examples/webengine/src/main.rs @@ -1,4 +1,3 @@ -extern crate qmetaobject; use qmetaobject::*; qrc!(my_resource, diff --git a/qmetaobject/src/connections.rs b/qmetaobject/src/connections.rs index b70a023a..a058db5e 100644 --- a/qmetaobject/src/connections.rs +++ b/qmetaobject/src/connections.rs @@ -84,6 +84,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #![deny(missing_docs)] use std::os::raw::c_void; +use cpp::{cpp, cpp_class}; + use super::*; /// Inner functor type of a `QRustClosureSlotObject` class. @@ -282,7 +284,7 @@ impl Signal { /// # Example /// /// ``` - /// #[macro_use] extern crate cpp; + /// use cpp::cpp; /// use qmetaobject::*; /// /// fn object_name_changed() -> Signal { diff --git a/qmetaobject/src/future.rs b/qmetaobject/src/future.rs index f96c9d11..88ab6243 100644 --- a/qmetaobject/src/future.rs +++ b/qmetaobject/src/future.rs @@ -4,6 +4,8 @@ use std::os::raw::c_void; use std::pin::Pin; use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; +use cpp::cpp; + use crate::connections::SignalArgArrayToTuple; static QT_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new( diff --git a/qmetaobject/src/itemmodel.rs b/qmetaobject/src/itemmodel.rs index a2deede9..13134bc3 100644 --- a/qmetaobject/src/itemmodel.rs +++ b/qmetaobject/src/itemmodel.rs @@ -18,6 +18,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. use std::collections::HashMap; +use cpp::cpp; + use crate::*; /// This trait allow to override a Qt QAbstractItemModel diff --git a/qmetaobject/src/lib.rs b/qmetaobject/src/lib.rs index d64c4b90..e0073069 100644 --- a/qmetaobject/src/lib.rs +++ b/qmetaobject/src/lib.rs @@ -21,8 +21,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # Example: ``` - #[macro_use] extern crate cstr; - + use cstr::cstr; use qmetaobject::*; // The `QObject` custom derive macro allows to expose a class to Qt and QML @@ -155,18 +154,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #![cfg_attr(feature = "cargo-clippy", allow(clippy::needless_pass_by_value))] // Too many of that for qt types. (FIXME) #![cfg_attr(feature = "cargo-clippy", allow(clippy::cognitive_complexity))] -#[macro_use] -extern crate cpp; - #[doc(hidden)] pub use qmetaobject_impl::*; // In order to be able to use the lazy_static macro from the QObject custom derive, we re-export // it under a new name qmetaobject_lazy_static. -extern crate lazy_static; #[allow(unused_imports)] #[doc(hidden)] -pub use lazy_static::*; +pub use lazy_static::lazy_static; #[doc(hidden)] #[macro_export] macro_rules! qmetaobject_lazy_static { ($($t:tt)*) => { lazy_static!($($t)*) } } @@ -175,6 +170,8 @@ use std::cell::{RefCell, RefMut}; use std::ffi::{CStr, CString}; use std::os::raw::{c_char, c_void}; +use cpp::{cpp, cpp_class}; + pub use qttypes; pub use crate::log::*; diff --git a/qmetaobject/src/listmodel.rs b/qmetaobject/src/listmodel.rs index 3a8e6316..99209fde 100644 --- a/qmetaobject/src/listmodel.rs +++ b/qmetaobject/src/listmodel.rs @@ -16,11 +16,14 @@ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -use super::*; use std::collections::HashMap; use std::iter::FromIterator; use std::ops::Index; +use cpp::cpp; + +use super::*; + /// This trait allow to override a Qt QAbstractListModel pub trait QAbstractListModel: QObject { /// Required for the implementation detail of the QObject custom derive diff --git a/qmetaobject/src/log.rs b/qmetaobject/src/log.rs index a7e4df74..b92c846f 100644 --- a/qmetaobject/src/log.rs +++ b/qmetaobject/src/log.rs @@ -3,6 +3,8 @@ use std::ffi::CStr; use std::os::raw::c_char; +use cpp::{cpp, cpp_class}; + #[cfg(feature = "log")] use log::{logger, Level, Record, RecordBuilder}; diff --git a/qmetaobject/src/qmetatype.rs b/qmetaobject/src/qmetatype.rs index 2271b3eb..695592c7 100644 --- a/qmetaobject/src/qmetatype.rs +++ b/qmetaobject/src/qmetatype.rs @@ -15,6 +15,8 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +use cpp::cpp; + use super::*; fn register_metatype_common( diff --git a/qmetaobject/src/qrc.rs b/qmetaobject/src/qrc.rs index 82ca67eb..0126afd7 100644 --- a/qmetaobject/src/qrc.rs +++ b/qmetaobject/src/qrc.rs @@ -15,6 +15,7 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +use cpp::cpp; cpp! {{ Q_CORE_EXPORT bool qRegisterResourceData(int, const unsigned char *, diff --git a/qmetaobject/src/qtdeclarative.rs b/qmetaobject/src/qtdeclarative.rs index 4c021e6a..a14492af 100644 --- a/qmetaobject/src/qtdeclarative.rs +++ b/qmetaobject/src/qtdeclarative.rs @@ -15,6 +15,8 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +use cpp::{cpp, cpp_class}; + use crate::scenegraph::*; use crate::*; diff --git a/qmetaobject/src/scenegraph.rs b/qmetaobject/src/scenegraph.rs index ac826818..f99ec78f 100644 --- a/qmetaobject/src/scenegraph.rs +++ b/qmetaobject/src/scenegraph.rs @@ -15,6 +15,7 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +use cpp::cpp; use super::*; @@ -118,7 +119,6 @@ impl SGNode { /// call reset() if you want to change the size. /// /// ``` - /// extern crate qttypes; /// # use qmetaobject::{QObject, qtdeclarative::QQuickItem}; /// use qmetaobject::scenegraph::{SGNode, ContainerNode, RectangleNode}; /// use qttypes::QRectF; @@ -181,7 +181,6 @@ impl SGNode { /// In this example, the node has two children node /// /// ``` - /// extern crate qttypes; /// # use qmetaobject::{QObject, qtdeclarative::QQuickItem}; /// use qmetaobject::scenegraph::{SGNode, ContainerNode, RectangleNode}; /// use qttypes::QRectF; diff --git a/qmetaobject/src/tablemodel.rs b/qmetaobject/src/tablemodel.rs index a6fb7cea..a808c0e0 100644 --- a/qmetaobject/src/tablemodel.rs +++ b/qmetaobject/src/tablemodel.rs @@ -1,6 +1,9 @@ -use super::*; use std::collections::HashMap; +use cpp::cpp; + +use super::*; + pub trait QAbstractTableModel: QObject { fn get_object_description() -> &'static QObjectDescription where diff --git a/qmetaobject/src/webengine.rs b/qmetaobject/src/webengine.rs index b3df0397..bc5c3df9 100644 --- a/qmetaobject/src/webengine.rs +++ b/qmetaobject/src/webengine.rs @@ -1,3 +1,5 @@ +use cpp::cpp; + cpp! {{ #include }} diff --git a/qmetaobject/tests/common/mod.rs b/qmetaobject/tests/common/mod.rs index bcbd1d2b..19e4ce63 100644 --- a/qmetaobject/tests/common/mod.rs +++ b/qmetaobject/tests/common/mod.rs @@ -18,10 +18,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #![allow(dead_code)] -use qmetaobject::*; use std::cell::RefCell; use std::sync::Mutex; +use qmetaobject::*; + lazy_static! { pub static ref TEST_MUTEX: Mutex<()> = Mutex::new(()); pub static ref QML_LOGS: Mutex> = Mutex::new(Vec::new()); diff --git a/qmetaobject/tests/models.rs b/qmetaobject/tests/models.rs index 2697f30d..042dfe7d 100644 --- a/qmetaobject/tests/models.rs +++ b/qmetaobject/tests/models.rs @@ -15,15 +15,13 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +use std::cell::RefCell; +use std::iter::FromIterator; -extern crate qmetaobject; use qmetaobject::*; mod common; -use common::*; - -use std::cell::RefCell; -use std::iter::FromIterator; +use self::common::*; #[test] fn simple_model() { diff --git a/qmetaobject/tests/tests.rs b/qmetaobject/tests/tests.rs index e12d6d84..ae58c42b 100644 --- a/qmetaobject/tests/tests.rs +++ b/qmetaobject/tests/tests.rs @@ -15,18 +15,14 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -extern crate qmetaobject; -use qmetaobject::*; - -extern crate lazy_static; use std::cell::RefCell; use std::ffi::CStr; use std::rc::Rc; -extern crate tempfile; +use qmetaobject::*; mod common; -use common::*; +use self::common::*; #[test] fn self_test() { diff --git a/qmetaobject_impl/src/lib.rs b/qmetaobject_impl/src/lib.rs index 9cd4dcd1..dd2a00e1 100644 --- a/qmetaobject_impl/src/lib.rs +++ b/qmetaobject_impl/src/lib.rs @@ -22,14 +22,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))] // Because we copy-paste constants from Qt #![cfg_attr(feature = "cargo-clippy", allow(clippy::cognitive_complexity))] -#[macro_use] -extern crate syn; -#[macro_use] -extern crate quote; - -extern crate proc_macro; -extern crate proc_macro2; use proc_macro::TokenStream; +use quote::{quote, ToTokens}; +use syn::DeriveInput; mod qbjs; mod qobject_impl; @@ -38,7 +33,7 @@ mod simplelistitem_impl; /// Get the tokens to refer to the qmetaobject crate. By default, return "::qmetaobject" unless /// the QMetaObjectCrate is specified -fn get_crate(input: &syn::DeriveInput) -> impl quote::ToTokens { +fn get_crate(input: &DeriveInput) -> impl ToTokens { for i in input.attrs.iter() { if let Ok(x) = i.parse_meta() { if x.path().is_ident("QMetaObjectCrate") { diff --git a/qmetaobject_impl/src/qbjs.rs b/qmetaobject_impl/src/qbjs.rs index bd0f76c4..0836dfd5 100644 --- a/qmetaobject_impl/src/qbjs.rs +++ b/qmetaobject_impl/src/qbjs.rs @@ -15,7 +15,6 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -use std; // That's the same as parent::write_u32, but it should always be little endian fn write_u32(val: u32) -> [u8; 4] { diff --git a/qmetaobject_impl/src/qobject_impl.rs b/qmetaobject_impl/src/qobject_impl.rs index 236a3d34..64a3befa 100644 --- a/qmetaobject_impl/src/qobject_impl.rs +++ b/qmetaobject_impl/src/qobject_impl.rs @@ -15,12 +15,14 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -use super::qbjs; -use proc_macro::TokenStream; -use quote::ToTokens; use std::iter::Iterator; -use syn; + +use proc_macro::TokenStream; +use quote::{quote, ToTokens}; use syn::parse::{Parse, ParseStream, Parser, Result}; +use syn::{parse_macro_input, parse_quote, DeriveInput, Token}; + +use super::qbjs; macro_rules! unwrap_parse_error( ($e:expr) => { @@ -315,7 +317,7 @@ fn map_method_parameters2( } pub fn generate(input: TokenStream, is_qobject: bool) -> TokenStream { - let ast = parse_macro_input!(input as syn::DeriveInput); + let ast = parse_macro_input!(input as DeriveInput); let name = &ast.ident; @@ -989,7 +991,7 @@ fn is_valid_repr_attribute(attribute: &syn::Attribute) -> bool { } pub fn generate_enum(input: TokenStream) -> TokenStream { - let ast = parse_macro_input!(input as syn::DeriveInput); + let ast = parse_macro_input!(input as DeriveInput); let name = &ast.ident; diff --git a/qmetaobject_impl/src/qrc_impl.rs b/qmetaobject_impl/src/qrc_impl.rs index 20e6d15a..ef3aa36b 100644 --- a/qmetaobject_impl/src/qrc_impl.rs +++ b/qmetaobject_impl/src/qrc_impl.rs @@ -15,14 +15,15 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -use proc_macro::TokenStream; use std::collections::BTreeMap; use std::env; use std::fs; use std::path::PathBuf; +use proc_macro::TokenStream; +use quote::quote; use syn::parse::{Parse, ParseStream, Result}; -use syn::{Ident, LitStr, Token, Visibility}; +use syn::{braced, parse_macro_input, Ident, LitStr, Token, Visibility}; /// Function with this name and visibility modifier will be generated by the `qrc!` macro. struct TargetFunc { diff --git a/qmetaobject_impl/src/simplelistitem_impl.rs b/qmetaobject_impl/src/simplelistitem_impl.rs index f0924c3e..f594e4c0 100644 --- a/qmetaobject_impl/src/simplelistitem_impl.rs +++ b/qmetaobject_impl/src/simplelistitem_impl.rs @@ -16,10 +16,11 @@ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ use proc_macro::TokenStream; -use syn; +use quote::quote; +use syn::{parse_macro_input, DeriveInput}; pub fn derive(input: TokenStream) -> TokenStream { - let input = parse_macro_input!(input as syn::DeriveInput); + let input = parse_macro_input!(input as DeriveInput); let crate_ = super::get_crate(&input); let values = if let syn::Data::Struct(ref data) = input.data {