Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Support sea-orm
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Mar 8, 2023
1 parent a952fc0 commit 18ba867
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
19 changes: 12 additions & 7 deletions strum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "strum"
name = "sea-strum"
version = "0.24.0"
edition = "2018"
authors = ["Peter Glotfelty <[email protected]>"]
Expand All @@ -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"]
Expand Down
11 changes: 7 additions & 4 deletions strum_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "strum_macros"
name = "sea-strum_macros"
version = "0.24.0"
edition = "2018"
authors = ["Peter Glotfelty <[email protected]>"]
Expand All @@ -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]
Expand All @@ -27,3 +27,6 @@ syn = { version = "1.0", features = ["parsing", "extra-traits"] }

[dev-dependencies]
strum = "0.24"

[features]
sea-orm = []
15 changes: 12 additions & 3 deletions strum_macros/src/helpers/type_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
4 changes: 2 additions & 2 deletions strum_nostd_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions strum_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 18ba867

Please sign in to comment.