Implement defmt for v2 - #391
Open
darkwater wants to merge 1 commit into
Open
Conversation
alejandro-vaz
suggested changes
Aug 23, 2026
Comment on lines
+566
to
+577
| #[cfg(all(feature = "extract_if", feature = "defmt"))] | ||
| #[cfg_attr(docsrs, doc(cfg(feature = "defmt")))] | ||
| impl<T, const N: usize, F> defmt::Format for ExtractIf<'_, T, N, F> | ||
| where | ||
| F: FnMut(&mut T) -> bool, | ||
| T: defmt::Format, | ||
| { | ||
| fn format(&self, fmt: defmt::Formatter) { | ||
| defmt::write!(fmt, "ExtractIf({:?})", self.vec.as_slice()); | ||
| } | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
separate this into its own file defmt.rs and conditionally link it
Comment on lines
+654
to
+664
| #[cfg(feature = "defmt")] | ||
| impl<'a, I, const N: usize> defmt::Format for Splice<'a, I, N> | ||
| where | ||
| I: Iterator + 'a, | ||
| <I as Iterator>::Item: defmt::Format, | ||
| { | ||
| fn format(&self, fmt: defmt::Formatter) { | ||
| defmt::write!(fmt, "Splice({:?})", self.drain); | ||
| } | ||
| } | ||
|
|
Comment on lines
+2878
to
+2904
| #[cfg(feature = "defmt")] | ||
| #[cfg_attr(docsrs, doc(cfg(feature = "defmt")))] | ||
| impl<T: defmt::Format, const N: usize> defmt::Format for SmallVec<T, N> { | ||
| fn format(&self, fmt: defmt::Formatter) { | ||
| defmt::write!(fmt, "{=[?]}", self.as_slice()); | ||
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "defmt")] | ||
| #[cfg_attr(docsrs, doc(cfg(feature = "defmt")))] | ||
| impl<T: defmt::Format, const N: usize> defmt::Format for IntoIter<T, N> { | ||
| fn format(&self, fmt: defmt::Formatter) { | ||
| defmt::write!(fmt, "IntoIter({=[?]})", self.as_slice()); | ||
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "defmt")] | ||
| #[cfg_attr(docsrs, doc(cfg(feature = "defmt")))] | ||
| impl<T: defmt::Format, const N: usize> defmt::Format for Drain<'_, T, N> | ||
| where | ||
| T: defmt::Format, | ||
| { | ||
| fn format(&self, fmt: defmt::Formatter) { | ||
| defmt::write!(fmt, "Drain({=[?]})", self.iter.as_slice()); | ||
| } | ||
| } | ||
|
|
| specialization = [] | ||
| may_dangle = [] | ||
| extract_if = [] | ||
|
|
Contributor
There was a problem hiding this comment.
add the feature here, and add "dep:defmt" inside it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #389 for v2 (also see #390)