diff --git a/Cargo.toml b/Cargo.toml index 25e2dca..964c420 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,12 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/Artem-Romanenia/o2o" [dependencies] -o2o-impl = { version = "0.4.9-alpha.1", path = "o2o-impl" } -o2o-macros = { version = "0.4.9-alpha.1", path = "o2o-macros" } +o2o-impl = { version = "0.4.9-alpha.1", path = "o2o-impl", optional = true } +o2o-macros = { version = "0.4.9-alpha.1", path = "o2o-macros", optional = true } + +[features] +default = ["macro"] +macro = ["dep:o2o-impl", "dep:o2o-macros"] [workspace] members = ["o2o-impl", "o2o-macros", "o2o-tests"] diff --git a/o2o-impl/src/expand.rs b/o2o-impl/src/expand.rs index bbe91ac..bd93fd4 100644 --- a/o2o-impl/src/expand.rs +++ b/o2o-impl/src/expand.rs @@ -22,10 +22,7 @@ pub fn derive(node: &DeriveInput) -> Result { validate(&input)?; Ok(data_type_impl(input)) }, - _ => Err(Error::new_spanned( - node, - "#[derive(o2o)] only supports structs and enums.", - )) + _ => Err(Error::new_spanned(node, "#[derive(o2o)] only supports structs and enums.")) } } @@ -384,7 +381,7 @@ fn struct_init_block<'a>(input: &'a Struct, ctx: &ImplContext) -> TokenStream { unique_paths.insert(path); make_tuple(path, FieldData::Field(x)) }).collect::>()); - + fields.extend(input.attrs.ghosts_attrs.iter() .flat_map(|x| &x.attr.ghost_data) .filter(|x| unique_paths.insert(x.get_child_path_str(None))) diff --git a/src/lib.rs b/src/lib.rs index b816f64..54da9ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,6 @@ #![doc = include_str!("../README.md")] -extern crate o2o_impl; -extern crate o2o_macros; +#[cfg(feature = "macro")] +pub use o2o_macros::*; pub mod traits; - -pub use o2o_macros::*; \ No newline at end of file