|
56 | 56 | //! For details, see the
|
57 | 57 | //! [Rust Reference](https://doc.rust-lang.org/reference/const_eval.html#const-functions).
|
58 | 58 | //!
|
| 59 | +//! ### `defmt` |
| 60 | +//! |
| 61 | +//! When this feature is enabled, `SmallVec` implements the `defmt::Format` trait. |
| 62 | +//! |
59 | 63 | //! ### `drain_filter`
|
60 | 64 | //!
|
61 | 65 | //! **This feature is unstable.** It may change to match the unstable `drain_filter` method in libstd.
|
@@ -295,6 +299,7 @@ impl<T: Clone> ExtendFromSlice<T> for Vec<T> {
|
295 | 299 | }
|
296 | 300 |
|
297 | 301 | /// Error type for APIs with fallible heap allocation
|
| 302 | +#[cfg_attr(feature = "defmt", derive(defmt::Format))] |
298 | 303 | #[derive(Debug)]
|
299 | 304 | pub enum CollectionAllocErr {
|
300 | 305 | /// Overflow `usize::MAX` or other error during size computation
|
@@ -364,6 +369,16 @@ where
|
364 | 369 | }
|
365 | 370 | }
|
366 | 371 |
|
| 372 | +#[cfg(feature = "defmt")] |
| 373 | +impl<'a, T: 'a + Array> defmt::Format for Drain<'a, T> |
| 374 | +where |
| 375 | + T::Item: defmt::Format, |
| 376 | +{ |
| 377 | + fn format(&self, fmt: defmt::Formatter) { |
| 378 | + defmt::write!(fmt, "Drain({=[?]})", self.iter.as_slice()); |
| 379 | + } |
| 380 | +} |
| 381 | + |
367 | 382 | unsafe impl<'a, T: Sync + Array> Sync for Drain<'a, T> {}
|
368 | 383 | unsafe impl<'a, T: Send + Array> Send for Drain<'a, T> {}
|
369 | 384 |
|
@@ -2122,6 +2137,16 @@ where
|
2122 | 2137 | }
|
2123 | 2138 | }
|
2124 | 2139 |
|
| 2140 | +#[cfg(feature = "defmt")] |
| 2141 | +impl<A: Array> defmt::Format for SmallVec<A> |
| 2142 | +where |
| 2143 | + A::Item: defmt::Format, |
| 2144 | +{ |
| 2145 | + fn format(&self, fmt: defmt::Formatter) { |
| 2146 | + defmt::write!(fmt, "{=[?]}", self.as_slice()); |
| 2147 | + } |
| 2148 | +} |
| 2149 | + |
2125 | 2150 | impl<A: Array> Default for SmallVec<A> {
|
2126 | 2151 | #[inline]
|
2127 | 2152 | fn default() -> SmallVec<A> {
|
@@ -2245,6 +2270,16 @@ where
|
2245 | 2270 | }
|
2246 | 2271 | }
|
2247 | 2272 |
|
| 2273 | +#[cfg(feature = "defmt")] |
| 2274 | +impl<A: Array> defmt::Format for IntoIter<A> |
| 2275 | +where |
| 2276 | + A::Item: defmt::Format, |
| 2277 | +{ |
| 2278 | + fn format(&self, fmt: defmt::Formatter) { |
| 2279 | + defmt::write!(fmt, "IntoIter({=[?]})", self.as_slice()); |
| 2280 | + } |
| 2281 | +} |
| 2282 | + |
2248 | 2283 | impl<A: Array + Clone> Clone for IntoIter<A>
|
2249 | 2284 | where
|
2250 | 2285 | A::Item: Clone,
|
|
0 commit comments