From 8732758982556515c9ccea1adf577ca2d1e62e38 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 2 Nov 2024 01:19:39 -0400 Subject: [PATCH] Reexport Case --- Cargo.lock | 11 ++++++++++- Cargo.toml | 23 +++++++++++++++++------ src/lib.rs | 7 ++++--- tests/Cargo.toml | 12 ++++++++++++ tests/{enums.rs => src/lib.rs} | 2 ++ 5 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 tests/Cargo.toml rename tests/{enums.rs => src/lib.rs} (99%) diff --git a/Cargo.lock b/Cargo.lock index 28f99d5..488bf43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ dependencies = [ [[package]] name = "bindgen_helpers" -version = "0.1.0" +version = "0.1.1" dependencies = [ "bindgen", "convert_case", @@ -41,6 +41,15 @@ dependencies = [ "regex", ] +[[package]] +name = "bindgen_helpers_tests" +version = "0.0.0" +dependencies = [ + "bindgen", + "bindgen_helpers", + "insta", +] + [[package]] name = "bitflags" version = "2.6.0" diff --git a/Cargo.toml b/Cargo.toml index 74f46e6..58e5cb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,14 @@ +[workspace] +resolver = "2" +members = [".", "tests"] +default-members = [".", "tests"] + +[workspace.dependencies] +bindgen = "0.*" +convert_case = "0.6.0" +insta = "1.41.1" +regex = "1.11.1" + [package] name = "bindgen_helpers" version = "0.1.1" @@ -11,16 +22,16 @@ categories = ["development-tools::ffi", "development-tools::build-utils"] rust-version = "1.81.0" [dependencies] -bindgen = "0.*" -convert_case = "0.6.0" -regex = "1.11.1" +bindgen.workspace = true +convert_case.workspace = true +regex.workspace = true [dev-dependencies] -insta = "1.41.1" +insta.workspace = true -[lints.rust] +[workspace.lints.rust] unsafe_code = "forbid" unused_qualifications = "warn" -[lints.clippy] +[workspace.lints.clippy] pedantic = { level = "warn", priority = -1 } diff --git a/src/lib.rs b/src/lib.rs index 25c8efd..4b96d72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,8 @@ use std::collections::HashMap; -use convert_case::{Case, Casing}; +pub use convert_case::Case; +use convert_case::Casing as _; use regex::Regex; #[derive(Debug, Default)] @@ -183,9 +184,9 @@ macro_rules! rename_enum { $crate::IdentRenamer { $( rm_prefix: Some($rm_prefix.into()), )? $( rm_suffix: Some($rm_suffix.into()), )? - $( case: Some(convert_case::Case::$case), )? + $( case: Some($crate::Case::$case), )? renames: vec![$( ($itm.into(), $ren.into()), )*].into_iter().collect(), - ..$crate::IdentRenamer::default_case(convert_case::Case::Pascal) + ..$crate::IdentRenamer::default_case($crate::Case::Pascal) } ); }; diff --git a/tests/Cargo.toml b/tests/Cargo.toml new file mode 100644 index 0000000..0efa120 --- /dev/null +++ b/tests/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "bindgen_helpers_tests" +description = "Tests for bindgen_helpers, cleanly separated from the main crate to ensure no dependencies are leaked" +edition = "2021" +license = "MIT OR Apache-2.0" +version = "0.0.0" +publish = false + +[dev-dependencies] +bindgen.workspace = true +bindgen_helpers = { path = ".." } +insta.workspace = true diff --git a/tests/enums.rs b/tests/src/lib.rs similarity index 99% rename from tests/enums.rs rename to tests/src/lib.rs index 64763af..b0918c2 100644 --- a/tests/enums.rs +++ b/tests/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg(test)] + use bindgen::Builder; use bindgen_helpers::{rename_enum, Renamer}; use insta::assert_snapshot;