Skip to content

Commit b542d82

Browse files
authored
feat: Support smallvec from ShrinkToFit (#65)
1 parent d286027 commit b542d82

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

Cargo.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ rustc-hash = "1.1.0"
3030
serde = "1.0.192"
3131
serde_derive = "1.0.193"
3232
serde_json = { version = "1", default-features = false }
33+
smallvec = { version = "1", default-features = false }
3334
syn = "2.0.39"
3435
toml_edit = "0.22.20"
3536
triomphe = "0.1.11"

crates/shrink-to-fit/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ edition = { workspace = true }
44
license = { workspace = true }
55
name = "shrink-to-fit"
66
repository = { workspace = true }
7-
version = "0.2.9"
7+
version = "0.2.10"
88

99
[package.metadata.docs.rs]
1010
all-features = true
@@ -15,13 +15,14 @@ hashbrown = { workspace = true, optional = true, default-features = fa
1515
indexmap = { workspace = true, optional = true, default-features = false }
1616
serde_json = { workspace = true, optional = true, default-features = false }
1717
shrink-to-fit-macro = { version = "0.2.5", path = "../shrink-to-fit-macro", optional = true }
18-
18+
smallvec = { workspace = true, optional = true, default-features = false }
1919

2020
[features]
2121
default = ["derive"]
2222
derive = ["dep:shrink-to-fit-macro"]
2323
hashbrown = ["dep:hashbrown"]
2424
indexmap = ["dep:indexmap"]
2525
serde_json = ["dep:serde_json"]
26+
smallvec = ["dep:smallvec"]
2627
# Specialization for nightly. `ShrinkToFit` will be called for `T` in `Vec<T>` and collection elements if T implements `ShrinkToFit`.
2728
nightly = []

crates/shrink-to-fit/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,13 @@ where
205205
self.shrink_to_fit();
206206
}
207207
}
208+
209+
#[cfg(feature = "smallvec")]
210+
impl<T> ShrinkToFit for smallvec::SmallVec<T>
211+
where
212+
T: smallvec::Array,
213+
{
214+
fn shrink_to_fit(&mut self) {
215+
self.shrink_to_fit();
216+
}
217+
}

0 commit comments

Comments
 (0)