From 18ba867d37b84814067accf473f7fbd57e90ab28 Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Sat, 25 Dec 2021 17:37:45 +0800 Subject: [PATCH] Support sea-orm --- strum/Cargo.toml | 19 ++++++++++++------- strum_macros/Cargo.toml | 11 +++++++---- strum_macros/src/helpers/type_props.rs | 15 ++++++++++++--- strum_nostd_tests/Cargo.toml | 4 ++-- strum_tests/Cargo.toml | 4 ++-- 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/strum/Cargo.toml b/strum/Cargo.toml index ca4dd8f3..03a3613e 100644 --- a/strum/Cargo.toml +++ b/strum/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "strum" +name = "sea-strum" version = "0.24.0" edition = "2018" authors = ["Peter Glotfelty "] @@ -9,25 +9,30 @@ description = "Helpful macros for working with enums and strings" keywords = ["enum", "string", "macros", "proc-macros"] categories = ["development-tools::procedural-macro-helpers", "parsing"] -documentation = "https://docs.rs/strum" -homepage = "https://github.com/Peternator7/strum" -repository = "https://github.com/Peternator7/strum" +documentation = "https://docs.rs/sea-strum" +homepage = "https://github.com/SeaQL/strum" +repository = "https://github.com/SeaQL/strum" readme = "../README.md" +[lib] +name = "strum" +path = "src/lib.rs" + [dependencies] -strum_macros = { path = "../strum_macros", optional = true, version = "0.24" } +sea-strum_macros = { path = "../strum_macros", optional = true, version = "0.24" } phf = { version = "0.10", features = ["macros"], optional = true } [dev-dependencies] -strum_macros = { path = "../strum_macros", version = "0.24" } +sea-strum_macros = { path = "../strum_macros", version = "0.24" } [badges] travis-ci = { repository = "Peternator7/strum" } [features] default = ["std"] -derive = ["strum_macros"] +derive = ["sea-strum_macros"] std = [] +sea-orm = ["sea-strum_macros/sea-orm"] [package.metadata.docs.rs] features = ["derive"] diff --git a/strum_macros/Cargo.toml b/strum_macros/Cargo.toml index 5dfd3700..182d68d7 100644 --- a/strum_macros/Cargo.toml +++ b/strum_macros/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "strum_macros" +name = "sea-strum_macros" version = "0.24.0" edition = "2018" authors = ["Peter Glotfelty "] @@ -9,9 +9,9 @@ description = "Helpful macros for working with enums and strings" keywords = ["enum", "string", "macros", "proc-macros"] categories = ["development-tools::procedural-macro-helpers", "parsing"] -documentation = "https://docs.rs/strum" -homepage = "https://github.com/Peternator7/strum" -repository = "https://github.com/Peternator7/strum" +documentation = "https://docs.rs/sea-strum" +homepage = "https://github.com/SeaQL/strum" +repository = "https://github.com/SeaQL/strum" readme = "../README.md" [lib] @@ -27,3 +27,6 @@ syn = { version = "1.0", features = ["parsing", "extra-traits"] } [dev-dependencies] strum = "0.24" + +[features] +sea-orm = [] diff --git a/strum_macros/src/helpers/type_props.rs b/strum_macros/src/helpers/type_props.rs index 0d49e04e..1ec30993 100644 --- a/strum_macros/src/helpers/type_props.rs +++ b/strum_macros/src/helpers/type_props.rs @@ -109,8 +109,17 @@ impl HasTypeProperties for DeriveInput { impl StrumTypeProperties { pub fn crate_module_path(&self) -> Path { - self.crate_module_path - .as_ref() - .map_or_else(|| parse_quote!(::strum), |path| parse_quote!(#path)) + if let Some(path) = &self.crate_module_path { + parse_quote!(#path) + } else { + #[cfg(feature = "sea-orm")] + { + parse_quote!(sea_orm::strum) + } + #[cfg(not(feature = "sea-orm"))] + { + parse_quote!(::strum) + } + } } } diff --git a/strum_nostd_tests/Cargo.toml b/strum_nostd_tests/Cargo.toml index 1c0ee470..0fe7a4da 100644 --- a/strum_nostd_tests/Cargo.toml +++ b/strum_nostd_tests/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -strum = { path = "../strum", features = ["derive"] } -strum_macros = { path = "../strum_macros", features = [] } +sea-strum = { path = "../strum", features = ["derive"] } +sea-strum_macros = { path = "../strum_macros", features = [] } [dev-dependencies] rustversion = "1.0" \ No newline at end of file diff --git a/strum_tests/Cargo.toml b/strum_tests/Cargo.toml index 3a69cefb..80737bcf 100644 --- a/strum_tests/Cargo.toml +++ b/strum_tests/Cargo.toml @@ -9,8 +9,8 @@ default = [] test_phf = ["strum/phf"] [dependencies] -strum = { path = "../strum", features = ["derive"] } -strum_macros = { path = "../strum_macros", features = [] } +sea-strum = { path = "../strum", features = ["derive"] } +sea-strum_macros = { path = "../strum_macros", features = [] } clap = "=2.33.0" enum_variant_type = "=0.2.0" structopt = "0.2.18"