diff --git a/bounded-static/src/lib.rs b/bounded-static/src/lib.rs
index 1b01804..ee59ad4 100644
--- a/bounded-static/src/lib.rs
+++ b/bounded-static/src/lib.rs
@@ -823,29 +823,33 @@ impl IntoBoundedStatic for smol_str::SmolStr {
/// [`ToBoundedStatic`] impl for `smallvec::SmallVec`.
#[cfg(feature = "smallvec")]
-impl ToBoundedStatic for smallvec::SmallVec
+impl ToBoundedStatic for smallvec::SmallVec
where
- A: smallvec::Array + 'static,
- A::Item: Clone,
+ A: smallvec::Array- + ToBoundedStatic,
+ T: ToBoundedStatic,
+ ::Static: smallvec::Array
- ,
{
- type Static = Self;
+ type Static = smallvec::SmallVec;
fn to_static(&self) -> Self::Static {
- self.clone()
+ self.iter().map(ToBoundedStatic::to_static).collect()
}
}
-/// No-op [`IntoBoundedStatic`] impl for `smallvec::SmallVec`.
+/// [`IntoBoundedStatic`] impl for `smallvec::SmallVec`.
#[cfg(feature = "smallvec")]
-impl IntoBoundedStatic for smallvec::SmallVec
+impl IntoBoundedStatic for smallvec::SmallVec
where
- A: smallvec::Array + 'static,
- A::Item: Clone,
+ A: smallvec::Array
- + IntoBoundedStatic,
+ T: IntoBoundedStatic,
+ ::Static: smallvec::Array
- ,
{
- type Static = Self;
+ type Static = smallvec::SmallVec;
fn into_static(self) -> Self::Static {
- self
+ self.into_iter()
+ .map(IntoBoundedStatic::into_static)
+ .collect()
}
}
@@ -1604,6 +1608,16 @@ mod smallvec_tests {
ensure_static(small_vec.to_static());
ensure_static(small_vec.into_static());
}
+
+ #[test]
+ fn test_smallvec3() {
+ let x = String::from("foo");
+ let y = String::from("bar");
+ let buf = [Cow::Borrowed(x.as_str()), Cow::Borrowed(y.as_str())];
+ let small_vec: smallvec::SmallVec<_> = smallvec::SmallVec::from_buf(buf);
+ ensure_static(small_vec.to_static());
+ ensure_static(small_vec.into_static());
+ }
}
#[cfg(feature = "smartstring")]