diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1bf7614f..9ac7fe9c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
- The `bson-uuid-impl` feature now supports `bson::oid::ObjectId` as well ([#340](https://github.com/Aleph-Alpha/ts-rs/pull/340))
- Allow multile types to have the same `#[ts(export_to = "...")]` attribute and be exported to the same file ([#316](https://github.com/Aleph-Alpha/ts-rs/pull/316))
+- Add support for types from `smol_str` behind cargo feature `smol_str-impl`
### Fixes
diff --git a/Cargo.lock b/Cargo.lock
index ace8028b..002a63e1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -126,6 +126,15 @@ dependencies = [
"wyz",
]
+[[package]]
+name = "borsh"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed"
+dependencies = [
+ "cfg_aliases",
+]
+
[[package]]
name = "bson"
version = "2.11.0"
@@ -180,6 +189,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+[[package]]
+name = "cfg_aliases"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
+
[[package]]
name = "chrono"
version = "0.4.38"
@@ -828,6 +843,16 @@ dependencies = [
"version_check",
]
+[[package]]
+name = "smol_str"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "66eaf762c5af19db3108300515c8aa7a50efc90ff745f4c62288052ebf9fdd25"
+dependencies = [
+ "borsh",
+ "serde",
+]
+
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
@@ -1156,6 +1181,7 @@ dependencies = [
"semver",
"serde",
"serde_json",
+ "smol_str",
"thiserror",
"ts-rs-macros",
"url",
diff --git a/README.md b/README.md
index ccd8715d..b840f463 100644
--- a/README.md
+++ b/README.md
@@ -86,6 +86,7 @@ When running `cargo test`, the TypeScript bindings will be exported to the file
| ordered-float-impl | Implement `TS` for types from *ordered_float* |
| heapless-impl | Implement `TS` for types from *heapless* |
| semver-impl | Implement `TS` for types from *semver* |
+| smol_str-impl | Implement `TS` for types from *smol_str* |
diff --git a/ts-rs/Cargo.toml b/ts-rs/Cargo.toml
index 1b994ec1..8da5e7c5 100644
--- a/ts-rs/Cargo.toml
+++ b/ts-rs/Cargo.toml
@@ -31,6 +31,7 @@ indexmap-impl = ["indexmap"]
ordered-float-impl = ["ordered-float"]
heapless-impl = ["heapless"]
semver-impl = ["semver"]
+smolstr-impl = ["smol_str"]
serde-json-impl = ["serde_json"]
no-serde-warnings = ["ts-rs-macros/no-serde-warnings"]
import-esm = []
@@ -53,6 +54,7 @@ bson = { version = "2", optional = true }
bytes = { version = "1", optional = true }
url = { version = "2", optional = true }
semver = { version = "1", optional = true }
+smol_str = { version = "0.3", optional = true }
thiserror = "1"
indexmap = { version = "2", optional = true }
ordered-float = { version = ">= 3, < 5", optional = true }
diff --git a/ts-rs/src/lib.rs b/ts-rs/src/lib.rs
index 2f7b19cd..5e1ccfdc 100644
--- a/ts-rs/src/lib.rs
+++ b/ts-rs/src/lib.rs
@@ -84,6 +84,7 @@
//! | ordered-float-impl | Implement `TS` for types from *ordered_float* |
//! | heapless-impl | Implement `TS` for types from *heapless* |
//! | semver-impl | Implement `TS` for types from *semver* |
+//! | smol_str-impl | Implement `TS` for types from *smol_str* |
//!
//!
//!
@@ -994,6 +995,9 @@ impl_tuples!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10);
#[cfg(feature = "bigdecimal-impl")]
impl_primitives! { bigdecimal::BigDecimal => "string" }
+#[cfg(feature = "smolstr-impl")]
+impl_primitives! { smol_str::SmolStr => "string" }
+
#[cfg(feature = "uuid-impl")]
impl_primitives! { uuid::Uuid => "string" }
diff --git a/ts-rs/tests/integration/impl_primitive.rs b/ts-rs/tests/integration/impl_primitive.rs
new file mode 100644
index 00000000..893439bf
--- /dev/null
+++ b/ts-rs/tests/integration/impl_primitive.rs
@@ -0,0 +1,106 @@
+#[cfg(feature = "bigdecimal-impl")]
+#[test]
+fn impl_primitive_bigdecimal() {
+ assert_eq!(
+ ::name(),
+ ::name()
+ );
+ assert_eq!(
+ ::inline(),
+ ::inline()
+ )
+}
+
+#[cfg(feature = "smolstr-impl")]
+#[test]
+fn impl_primitive_smolstr() {
+ assert_eq!(
+ ::name(),
+ ::name()
+ );
+ assert_eq!(
+ ::inline(),
+ ::inline()
+ )
+}
+
+#[cfg(feature = "uuid-impl")]
+#[test]
+fn impl_primitive_uuid() {
+ assert_eq!(
+ ::name(),
+ ::name()
+ );
+ assert_eq!(
+ ::inline(),
+ ::inline()
+ )
+}
+
+#[cfg(feature = "url-impl")]
+#[test]
+fn impl_primitive_url() {
+ assert_eq!(
+ ::name(),
+ ::name()
+ );
+ assert_eq!(
+ ::inline(),
+ ::inline()
+ )
+}
+
+#[cfg(feature = "ordered-float-impl")]
+#[test]
+fn impl_primitive_order_float() {
+ assert_eq!(
+ as ts_rs::TS>::name(),
+ ::name()
+ );
+ assert_eq!(
+ as ts_rs::TS>::inline(),
+ ::inline()
+ );
+ assert_eq!(
+ as ts_rs::TS>::name(),
+ ::name()
+ );
+ assert_eq!(
+ as ts_rs::TS>::inline(),
+ ::inline()
+ )
+}
+
+#[cfg(feature = "bson-uuid-impl")]
+#[test]
+fn impl_primitive_bson_uuid() {
+ assert_eq!(
+ ::name(),
+ ::name()
+ );
+ assert_eq!(
+ ::inline(),
+ ::inline()
+ );
+ assert_eq!(
+ ::name(),
+ ::name()
+ );
+ assert_eq!(
+ ::inline(),
+ ::inline()
+ )
+}
+
+#[cfg(feature = "semver-impl")]
+#[test]
+fn impl_primitive_semver() {
+ assert_eq!(
+ ::name(),
+ ::name()
+ );
+ assert_eq!(
+ ::inline(),
+ ::inline()
+ )
+}
diff --git a/ts-rs/tests/integration/main.rs b/ts-rs/tests/integration/main.rs
index e1ce0e0c..05c3234d 100644
--- a/ts-rs/tests/integration/main.rs
+++ b/ts-rs/tests/integration/main.rs
@@ -20,6 +20,7 @@ mod generics;
mod generics_flatten;
mod hashmap;
mod hashset;
+mod impl_primitive;
mod imports;
mod indexmap;
mod infer_as;