From 14fe6d28bdff52f5b20fe9871774ce825befcc1f Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sun, 29 Jun 2025 14:56:32 +0530 Subject: [PATCH 1/9] doc comment added --- crates/tagged-core/src/lib.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/tagged-core/src/lib.rs b/crates/tagged-core/src/lib.rs index a582515..aaaf002 100644 --- a/crates/tagged-core/src/lib.rs +++ b/crates/tagged-core/src/lib.rs @@ -1,4 +1,29 @@ use std::ops::Deref; +/// rust-tagged provides a simple way to define strongly typed wrappers over primitive types like String, i32, Uuid, chrono::DateTime, etc. It helps eliminate bugs caused by misusing raw primitives for conceptually distinct fields such as UserId, Email, ProductId, and more. +/// +/// Eliminate accidental mixups between similar types (e.g. OrgId vs UserId) +/// Enforce domain modeling in code via the type system +/// Ergonomic .into() support for primitive conversions +/// +/// # Example +/// +/// ``` +/// use rust_tagged::{Tagged}; +/// +/// #[derive(Debug)] +/// struct EmailTag; +/// +/// type Email = Tagged; +/// +/// fn main() { +/// let email: Email = "test@example.com".into(); +/// println!("Email inner value: {}", email.value()); +/// +/// // Convert back to String +/// let raw: String = email.into(); +/// println!("Raw String: {raw}"); +/// } +/// ``` pub struct Tagged { value: T, _marker: std::marker::PhantomData, From 89acc1c080a28dafc8895eeb561e6e2252ecf9e9 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sun, 29 Jun 2025 15:38:15 +0530 Subject: [PATCH 2/9] lib added --- Cargo.toml | 32 +++++++++++++++++-- crates/tagged-core/Cargo.toml | 2 +- crates/tagged-core/examples/basic.rs | 2 +- .../examples/robust_types_solution.rs | 2 +- examples/basic.rs | 8 +++++ src/lib.rs | 9 ++++++ 6 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 examples/basic.rs create mode 100644 src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index b7a0891..b9e336d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ -[workspace.package] -# name = "rust-tagged" +[package] +name = "rust-tagged" version = "0.1.0" edition = "2024" authors = ["Codefonsi "] @@ -13,3 +13,31 @@ members = [ "crates/tagged-core", "crates/tagged-macros", ] + +#[lib] +#path = "crates/tagged-core/src/lib.rs" + +#[workspace.dependencies] +#tagged-core = {path = "crates/tagged-core"} +# +#[dependencies] +#tagged-core.workspace = true + +[workspace.dependencies] +tagged-core = { path = "crates/tagged-core", version = "0.1.0" } +#serde = { version = "1.0", optional = true, features = ["derive"] } +#uuid = { version = "1.4", optional = true } +#chrono = { version = "0.4", optional = true } + +[dependencies] +tagged-core.workspace = true +#serde = { version = "1.0", features = ["derive"] } +#uuid = { version = "1.4" } +#chrono = { version = "0.4" } + +# crates/tagged-core/Cargo.toml +[features] +default = [] +#serde = ["dep:serde"] +#uuid = ["dep:uuid"] +#chrono = ["dep:chrono"] diff --git a/crates/tagged-core/Cargo.toml b/crates/tagged-core/Cargo.toml index c200a45..92c99ac 100644 --- a/crates/tagged-core/Cargo.toml +++ b/crates/tagged-core/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rust-tagged" +name = "tagged-core" version = "0.1.0" edition = "2024" description = "A lightweight tagged type abstraction for type-safe IDs, etc." diff --git a/crates/tagged-core/examples/basic.rs b/crates/tagged-core/examples/basic.rs index 76b3658..c392e3f 100644 --- a/crates/tagged-core/examples/basic.rs +++ b/crates/tagged-core/examples/basic.rs @@ -1,4 +1,4 @@ -use rust_tagged::{Tagged}; +use tagged_core::{Tagged}; struct UserIdTag; fn main() { diff --git a/crates/tagged-core/examples/robust_types_solution.rs b/crates/tagged-core/examples/robust_types_solution.rs index eb12481..7a9841b 100644 --- a/crates/tagged-core/examples/robust_types_solution.rs +++ b/crates/tagged-core/examples/robust_types_solution.rs @@ -1,4 +1,4 @@ -use rust_tagged::Tagged; +use tagged_core::Tagged; struct Employee { id: Tagged, diff --git a/examples/basic.rs b/examples/basic.rs new file mode 100644 index 0000000..fc6b1f7 --- /dev/null +++ b/examples/basic.rs @@ -0,0 +1,8 @@ + +use tagged_core::Tagged; +struct UserIdTag; + +fn main() { + let id = Tagged::::new(42); + println!("Tagged value is : {}", id.value()); +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..8761f5f --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,9 @@ +pub mod rust_tagged { + pub use tagged_core::*; +} + +/* +we can also write it +*/ + +// pub use tagged_core::*; \ No newline at end of file From acb71ad7e045fb7824854ee9a7452721b8219062 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sun, 29 Jun 2025 15:46:33 +0530 Subject: [PATCH 3/9] publish --- Cargo.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index b9e336d..bf12b98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,14 @@ version = "0.1.0" edition = "2024" authors = ["Codefonsi "] license = "Mozilla Public License 2.0" +description = "A lightweight tagged type abstraction for type-safe IDs, etc." +repository = "https://github.com/codefonsi/rust-tagged" +homepage = "https://github.com/codefonsi/rust-tagged" +documentation = "https://docs.rs/rust-tagged" +keywords = ["tagged", "id", "type-safe", "newtype", "tagged-union"] +categories = ["data-structures"] +readme = "./README.md" +include = ["src/**/*", "Cargo.toml", "../../README.md", "LICENSE"] [workspace] From f12642199be5b8c2ce641572067d3091e1614dd8 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sun, 29 Jun 2025 16:04:16 +0530 Subject: [PATCH 4/9] publish wip --- .DS_Store | Bin 0 -> 6148 bytes Cargo.toml | 14 +++++++------- {crates/benches => benches}/proc_macro_bench.rs | 0 examples/basic.rs | 8 -------- src/lib.rs | 9 --------- .../tagged-chrono => tagged-chrono}/Cargo.toml | 0 .../tagged-chrono => tagged-chrono}/src/lib.rs | 0 tagged-core/.DS_Store | Bin 0 -> 6148 bytes {crates/tagged-core => tagged-core}/Cargo.toml | 0 .../examples/basic.rs | 0 .../examples/robust_types_problem.rs | 0 .../examples/robust_types_solution.rs | 0 {crates/tagged-core => tagged-core}/src/lib.rs | 0 tagged-macros/.DS_Store | Bin 0 -> 6148 bytes .../tagged-macros => tagged-macros}/Cargo.toml | 0 .../examples/basic.rs | 0 .../tagged-macros => tagged-macros}/src/lib.rs | 0 17 files changed, 7 insertions(+), 24 deletions(-) create mode 100644 .DS_Store rename {crates/benches => benches}/proc_macro_bench.rs (100%) delete mode 100644 examples/basic.rs delete mode 100644 src/lib.rs rename {crates/tagged-chrono => tagged-chrono}/Cargo.toml (100%) rename {crates/tagged-chrono => tagged-chrono}/src/lib.rs (100%) create mode 100644 tagged-core/.DS_Store rename {crates/tagged-core => tagged-core}/Cargo.toml (100%) rename {crates/tagged-core => tagged-core}/examples/basic.rs (100%) rename {crates/tagged-core => tagged-core}/examples/robust_types_problem.rs (100%) rename {crates/tagged-core => tagged-core}/examples/robust_types_solution.rs (100%) rename {crates/tagged-core => tagged-core}/src/lib.rs (100%) create mode 100644 tagged-macros/.DS_Store rename {crates/tagged-macros => tagged-macros}/Cargo.toml (100%) rename {crates/tagged-macros => tagged-macros}/examples/basic.rs (100%) rename {crates/tagged-macros => tagged-macros}/src/lib.rs (100%) diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c5db90b6db7daf174ecf5149016c08de7b9c544d GIT binary patch literal 6148 zcmeHK%}T>S5T4b7!J_o0$2>pnJK$pGCQ;T<%8Yn5|QcN4?9FHA_~wL8@uQ#jK{f^Y|DE%*|<3-G@`|H z+_@asQnWf$0af6yDZqPohx*vJw=|&K{!M0{>Pa~wv2om=+CD~txAtQ49DJTtMGZHI znoan$$W~)Iv`2SzLu33#G^8WPYfcsnt(+}cG+nKa&hvaaUGiKre_~ghH_NEt-z@RB zG^bIK`@uW7*F@%dKel@>ucB{l^osNM(M7%&ReC2-e*nfdJIgb@_j?t3=c4nxKOSoJ zE@Z5@Z;(p^u9^rh<}A#;uHb{L04PP>fq0{?LV!i3GJ*1yq5e z0^9Q1;`)DHfB!Eg>6::new(42); - println!("Tagged value is : {}", id.value()); -} diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 8761f5f..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod rust_tagged { - pub use tagged_core::*; -} - -/* -we can also write it -*/ - -// pub use tagged_core::*; \ No newline at end of file diff --git a/crates/tagged-chrono/Cargo.toml b/tagged-chrono/Cargo.toml similarity index 100% rename from crates/tagged-chrono/Cargo.toml rename to tagged-chrono/Cargo.toml diff --git a/crates/tagged-chrono/src/lib.rs b/tagged-chrono/src/lib.rs similarity index 100% rename from crates/tagged-chrono/src/lib.rs rename to tagged-chrono/src/lib.rs diff --git a/tagged-core/.DS_Store b/tagged-core/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d20629ed6a342b8747397c3af3d7da78a1f5bf45 GIT binary patch literal 6148 zcmeHKJ5Iwu5S>j@7}BJq+?EcP6i7>C=%{=Fh!Z7+En8Sfl)eC`K%9jGaRJ`!jN(`h z5*0!)Bh9|`d_4AB%d<;FZuzuMi55hZKp7_|7>)@0Sw}Ka3p-uBM?)oTs4cf?K8iNO zZ)89gcSFzgKouRVUr|?$Jn;M+m|$H8F;$&qtFm6P@AB&I^(}e7J|4IJR$Q}7^S+Ps=BW{_73au_ithh7z4(@zhMA9nJnp4{o(;gD*a^Y{agqv@RHsJ_C+V3S6HhTq75 zZtk9*=$1-4+P`g8*1F)+S73sD9mJGXo^Oh3!@kRh=J1ldUropDz7eDt2MM`E6ZN>Ji! Date: Sun, 29 Jun 2025 16:04:49 +0530 Subject: [PATCH 5/9] readme --- tagged-core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tagged-core/Cargo.toml b/tagged-core/Cargo.toml index 92c99ac..8fe040e 100644 --- a/tagged-core/Cargo.toml +++ b/tagged-core/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://github.com/akashsoni01/rust-tagged" documentation = "https://docs.rs/rust-tagged" keywords = ["tagged", "id", "type-safe", "newtype", "tagged-union"] categories = ["data-structures"] -readme = "../../README.md" +readme = "../README.md" include = ["src/**/*", "Cargo.toml", "../../README.md", "LICENSE"] [dependencies] From c6b62baef0ac2ef8c49380ce6a6cc57727d8b605 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sun, 29 Jun 2025 16:07:49 +0530 Subject: [PATCH 6/9] licence fixed --- tagged-core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tagged-core/Cargo.toml b/tagged-core/Cargo.toml index 8fe040e..09a201c 100644 --- a/tagged-core/Cargo.toml +++ b/tagged-core/Cargo.toml @@ -3,7 +3,7 @@ name = "tagged-core" version = "0.1.0" edition = "2024" description = "A lightweight tagged type abstraction for type-safe IDs, etc." -license = "Mozila-2.0" +license = "MPL-2.0" authors = ["Codefonsi "] repository = "https://github.com/akashsoni01/rust-tagged" homepage = "https://github.com/akashsoni01/rust-tagged" From 87ded64f9aa3e9bd2d783afb30bd351e432696c7 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sun, 29 Jun 2025 16:11:47 +0530 Subject: [PATCH 7/9] tagged publish wip --- Cargo.toml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b588308..4163c61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "rust-tagged" version = "0.1.0" edition = "2024" authors = ["Codefonsi "] -license = "Mozilla Public License 2.0" +license = "MPL-2.0" description = "A lightweight tagged type abstraction for type-safe IDs, etc." repository = "https://github.com/codefonsi/rust-tagged" homepage = "https://github.com/codefonsi/rust-tagged" @@ -28,10 +28,14 @@ members = [ #[workspace.dependencies] #tagged-core = {path = "crates/tagged-core"} # -#[dependencies] -#tagged-core.workspace = true -#[workspace.dependencies] +[patch.crates-io] +tagged-core = { path = "tagged-core" } + +[dependencies] +tagged-core = { version = "0.1.0" } # This will use the patched version from local + +[workspace.dependencies] #tagged-core = { path = "crates/tagged-core", version = "0.1.0" } #serde = { version = "1.0", optional = true, features = ["derive"] } #uuid = { version = "1.4", optional = true } From a6d75d8f9b67985af32062b7bb5515d24cb1b79c Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sun, 29 Jun 2025 16:14:36 +0530 Subject: [PATCH 8/9] publish --- examples/basic.rs | 7 +++++++ src/lib.rs | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 examples/basic.rs create mode 100644 src/lib.rs diff --git a/examples/basic.rs b/examples/basic.rs new file mode 100644 index 0000000..3bcbccd --- /dev/null +++ b/examples/basic.rs @@ -0,0 +1,7 @@ +use tagged_core::{Tagged}; + +struct UserIdTag; +fn main() { + let id = Tagged::::new(42); + println!("Tagged value is = {}", id.value()); +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..d0730d9 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,3 @@ +pub mod rust_tagged{ + pub use tagged_core::*; +} \ No newline at end of file From d613748f796669d63981f0990f49f1951ad97429 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sun, 29 Jun 2025 16:32:14 +0530 Subject: [PATCH 9/9] ignore updated --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 736992f..2ceade0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ target/ # These are backup files generated by rustfmt **/*.rs.bk - +**/*.DS_Store # MSVC Windows builds of rustc generate these, which store debugging information *.pdb